I am currently studying AES algorithm and writing a Code using Python. I am trying to add 'Salt' into the user input password,
Here is what I am doing,
import hashlib import os password = "Sufiyan Ghori" salt = os.urandom(32) # 32bytes * 8 = 256bits # Adding the Password into the first 128bits of SALT # So that the password could be encrypted Encoded_Password = password.encode('utf-8') + salt[:16] # Output will be, Password + Salt I've added comments above for better understanding.
If the 32-byte salt is equal to
b'\x937{\xa0\x9bo\x9f\x8b1\xbf\xa9\xc9\x01\x86\xa1\xd9\xc7\x00+\x81\t\x0f\\\xdc\ x9a\xe5\x84r\xce$EJ' then Password + Salt[:16] would be
b'Sufiyan Ghori\x937{\xa0\x9bo\x9f\x8b1\xbf\xa9\xc9\x01\x86\xa1\xd9' If I then create its digest using sha512,
sha512 = hashlib.sha512( Encoded_Password ).digest() the output will be
b"\xe8\x02\xcc\xa9\x1a\xd3\x1b\x80\x1f{\xd2\xa6E7\x9d\x87\xcf\x17\xb1\xb4\x07\xb 1\xfe\xf2\x9a\xa5\xcc\xe7\x92\xc0\x81\xed\xf8HPu\xe2'\xfc\x0b\xc1\xa6\xc8\xd0N5a \xc1;\xf7\xbc\xe3\xafN\xcaN\xdfqhc&A#%" How am I supposed to recover the original password — which is Sufiyan Ghori — from this fixed-length hash value now?