So I have to hash a user entered password and then write the hashed password to a file. The code I have puts the clear text password into the file not the hash.
This is my code for my function
Code for program file
What am I missing? Thanks!
This is my code for my function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import hashlib def writeHashedPswd(password): # try: myhash = hashlib.md5(password) myfile = open ( "password.txt" , "w" ) myfile.write(password + '/n' ) password = myhash.hexdigest() myfile.close() myfile = open ( "password.txt" , "a" ) myfile.write( "an error occured." ) myfile.close() |
1 2 3 4 |
import a8 password = raw_input ( 'Enter your password: ' ) a8.writeHashedPswd(password) |