checking user passwords
Davide Alberani
alberanid at bigfoot.togli.questo.com
Tue Mar 28 05:38:57 EST 2000
"Pete Shinners" <pete at visionart.com> wrote:
>
> under unix i'd like to verify a username and password.
I think you've to use pwd and crypt modules.
A really poor example:
#!/usr/bin/python
import pwd, crypt
uname = raw_input('Your username: ')
passwd = raw_input('Password: ')
# Here a KeyError exception may be raised.
pw = pwd.getpwnam(uname)[1]
crp = crypt.crypt(passwd, pw[:2])
if crp == pw:
print 'Ok!'
else:
print 'Error!'
+++
I'm not sure it works with shadow password.
--
Cinereview: Il Talento di Mr.Ripley: ottimo intreccio, buoni _/Davide\_
interpreti e regia. Voto: 8.5 \Alberani/
More information about the Python-list
mailing list