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.