Passwords

Published: Wednesday, Dec 26, 2007 Last modified: Monday, Apr 8, 2024

Storing passwords securely?

import md5

from getpass import getpass


password = 'test'


md5password = md5.new(password).digest()


while 1:

# echos input
#input = raw_input("Password:\n")

# this doesn't ! :)
input = getpass()

if md5password == md5.new(input).digest():
    print "Correct password!"
    break
else:
    print "Incorrect password sunshine! Try again"