So a while back I was working on a Cryptographic Hashing project for a class I am no longer in. The code works almost perfect but Prints out the letter "b" and then the given imput before t printing the hashes.
Example if imput is "I like pizza." Then the output wpuld be " b'I like pizza.'" then the hashes. Here is the code I figured a second set of eyes could give me an Idea of where I messed up. Its a mix of the code my professor provided and my own but it was about a year ago so I don't remember what is his and what is mine. He primarilly provided the hash list and the the code to import it from what I remember.
This is the code listed below:
import hashlib
import random
def main(s):
hash_list = [
hashlib.md5(),
hashlib.sha1(),
hashlib.sha224(),
hashlib.sha256(),
hashlib.blake2b()
]
hashing_name = ["md5", "sha1", "sha224", "sha256", "blake2b"]
length_of_salt = 13
salt = "".join(random.choice('0123456789') for i in range(length_of_salt))
hexa = hex(int(salt))
salt = hexa.split('x')[-1]
salt = hexa.encode('utf-8')
for i in range(5):
m = hash_list[i]
m.update(s+salt)
print("Testing hash algorithm", hashing_name[i], "Hashed Password = ", m.hexdigest()+":"+hexa)
if __name__ == "__main__":
s = input().encode('utf-8')
print(s)
main(s)
I was trying to get hashes, which I got, but it prints out extran information first.