How to encrypt password

1 view
Skip to first unread message

Ranjan

unread,
Dec 18, 2009, 7:43:18 AM12/18/09
to TurboGears
Hi All,

In TG 1, I was using the following code to encrypt the user given
password
identity.encrypt_password(data['pwd'])

In TG2, need help to use like that.

Regards,
Ranjan

Christoph Zwerschke

unread,
Dec 18, 2009, 7:47:23 AM12/18/09
to turbo...@googlegroups.com
Am 18.12.2009 13:43 schrieb Ranjan:
> In TG 1, I was using the following code to encrypt the user given
> password identity.encrypt_password(data['pwd'])
> In TG2, need help to use like that.

The setter method in the default auth.py model file already does that
for you automatically if you store a user password, and you can modify
the encryption method there as you like.

-- Christoph

Ranjan

unread,
Dec 21, 2009, 5:42:03 AM12/21/09
to TurboGears
In my change password method, I want to compare the user input
password and the encrypted password stored in database.
Needing help

Christoph Zwerschke

unread,
Dec 21, 2009, 3:43:46 PM12/21/09
to turbo...@googlegroups.com
Am 21.12.2009 11:42 schrieb Ranjan:
> In my change password method, I want to compare the user input
> password and the encrypted password stored in database.
> Needing help

You can use the User.validate_password() method for this purpose. Have a
look at the User class in the file model/auth.py.

-- Christoph

Ranjan

unread,
Dec 22, 2009, 1:06:29 AM12/22/09
to TurboGears
Thanks Christoph
Reply all
Reply to author
Forward
0 new messages