[web2py] Re: How to encrypt password

2021-07-30 Thread Dave S

On Friday, July 30, 2021 at 1:34:44 PM UTC-7 isi_jca wrote:

> Hi everybody:
>
> I was able to solve my problem. 
>
>>
>>
Good to hear!

/dps
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/43723c6b-86d8-4d84-a7df-cf60926d2681n%40googlegroups.com.


[web2py] Re: How to encrypt password

2021-07-30 Thread isi_jca
Hi everybody:

I was able to solve my problem. 

def validar_password(form):
entered_password = str(form.vars.new_password)
entered_password = entered_password.strip()
new_password = request.vars.new_password

   #Retrieve passwords
rows_password = db(db.thist_password.usrid == 
auth.user_id).select(db.thist_password.password)

for j in rows_password:
#Get digest_alg salt and el hash 
(digest_alg, salt, save_hash) = j.password.split('$')
stored_password = j.password

#Encrypt using the same salt 
new_hash = CRYPT(salt=salt)(new_password)[0]

if stored_password ==  new_hash :
form.errors.new_password = ('You can not repeat password')
break

Regards. 

El miércoles, 28 de julio de 2021 a las 16:36:08 UTC-3, isi_jca escribió:

>
>
> Hello!
>
> I was doing a test.
>
> rows_password = db(db.thist_password.usrid == 
> auth.user_id).select(db.thist_password.password)
> for j in rows_password:
> #Get digest_alg salt, hash and original hash
> (digest_alg, salt, save_hash) = j.password.split('$')
> 
> #Encrypt password
> hash_password = 
> str(CRYPT(digest_alg=digest_alg,key=new_password,salt=salt)('test')[0])
> (digest_alg, salt, new_hash) = hash_password.split('$')
>
> if new_hash ==  save_hash:
> form.errors.new_password = ('You can't repeat password')
> break
>
> But they are different
>
> save_hash: 3e7d5266c03b978652b572be1e781c1ec0c985e6 
> new_hash: 33c3e0c2606b92fadf1f7aac07f77981f5f254bd salt: b5e76116485249e1 
> digest_alg: pbkdf2(1000,20,sha512)
>
> save_hash: 0faac8814c1d26f1456a736634b1666320a19753 
> new_hash: 18a42ab5ab333ab7e21eb7e58591dd5c62885d60 salt: 936f3f68de018365 
> digest_alg: pbkdf2(1000,20,sha512)
>
> save_hash: e90398ceeaf18950bc04229fe3b2e73dc16f9896 
> new_hash: d9ca6c9d67702112b2ca5d3d344bab0aaadde276 salt: 98a1d6f146b1815b 
> digest_alg: pbkdf2(1000,20,sha512)
>
> Anybody have any idea what is wrong?
>
> Regards.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/aee1a4cb-333f-462c-abea-88f80e35d2e9n%40googlegroups.com.


[web2py] Re: How to encrypt password

2021-07-28 Thread isi_jca


Hello!

I was doing a test.

rows_password = db(db.thist_password.usrid == 
auth.user_id).select(db.thist_password.password)
for j in rows_password:
#Get digest_alg salt, hash and original hash
(digest_alg, salt, save_hash) = j.password.split('$')

#Encrypt password
hash_password = 
str(CRYPT(digest_alg=digest_alg,key=new_password,salt=salt)('test')[0])
(digest_alg, salt, new_hash) = hash_password.split('$')

if new_hash ==  save_hash:
form.errors.new_password = ('You can't repeat password')
break

But they are different

save_hash: 3e7d5266c03b978652b572be1e781c1ec0c985e6 
new_hash: 33c3e0c2606b92fadf1f7aac07f77981f5f254bd salt: b5e76116485249e1 
digest_alg: pbkdf2(1000,20,sha512)

save_hash: 0faac8814c1d26f1456a736634b1666320a19753 
new_hash: 18a42ab5ab333ab7e21eb7e58591dd5c62885d60 salt: 936f3f68de018365 
digest_alg: pbkdf2(1000,20,sha512)

save_hash: e90398ceeaf18950bc04229fe3b2e73dc16f9896 
new_hash: d9ca6c9d67702112b2ca5d3d344bab0aaadde276 salt: 98a1d6f146b1815b 
digest_alg: pbkdf2(1000,20,sha512)

Anybody have any idea what is wrong?

Regards.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b91c9992-61c6-43be-bfee-2a07b6f199d3n%40googlegroups.com.


[web2py] Re: How to encrypt password

2021-07-22 Thread Dave S


On Thursday, July 22, 2021 at 10:47:08 AM UTC-7 isi_jca wrote:

> Hello!
> I have a historical table where I save  n passwords by users so, I want to 
> validate in the next change password that the user don't repeat the 
> password. I need to encrypt the password and make a query in historical 
> table.
> How can I do to encrypt the password in Web2py?
>
> Best regards.



There are relevant validators in the FORM system.  Take a look at 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Complexity-and-security-validators>
and see if they help.  The CRYPT() validator should do what you need, I 
think.

This is aside from any tools in your front end.
 
/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6309c286-25dc-4b3d-88aa-687f15133fbbn%40googlegroups.com.