Ranger
Ranger

Reputation: 101

Python 3.4 Check Text Value of Hash

I am making a login program in python. One of its functions is creating an account of which the username and hashed password are stored in a text file. It was working fine, but I wanted to add password confirmation to it, so I added another password input and hashed it. When making an account 'guest', however, when I compare the hashes with a while loop like so:

while encryptedpass != encryptedpass2:
    confirmedpass = getpass.getpass(prompt = 'The passwords did not match. Please try again.')
    encryptedpass2 = hashlib.sha512(confpass.encode('ascii'))

it (the while loop) always runs. The reason is because the values of the variables, without entering a password and just pressing enter, are <sha512 HASH object @ 0x7f8276c09da0> and <sha512 HASH object @ 0x7f8276c09cb0>. They are both different. I would like to be able to check the actual text value of these hashes, but I do not know how to. Could someone please tell me how?

Upvotes: 0

Views: 58

Answers (1)

Untitled123
Untitled123

Reputation: 1293

I believe that adding .hexdigest() is the function you are looking for.

Upvotes: 1

Related Questions