Hashlib module and Pythonhashlib module in Python
Hashlib module in Python
This module is mainly used for data encryption. Encryption methods include md5, sha1_, sha384, sha512, sha1, sha3_224, sha3_256, sha3_384, and sha3_512. It converts data of any length into a fixed-length data string (usually expressed in hexadecimal strings) through a function ). Different encryption methods are used in the same way. Therefore, only the md5 encryption code is used here:
ImportHashlib
M = hashlib. md5 ()
M. update ('Hello'. Encode ('Utf8') # Encrypt the data 'hello' using md5
Print ('m = ', m. hexdigest () # print the encrypted result in hexadecimal notation. M = 5d41402abc4b2a76b9719d911017c592
B. update ('He'. Encode ('Utf8'))
B. update ('Llo'. Encode ('Utf8'))
Print ('B =', B. hexdigest () # perform step-by-step encryption and direct encryption. The result is the same as that of. B = 5d41402abc4b2a76b9719d911017c592.