python hash 1

python hash

import hashlib
hash_object = hashlib.sha256(b'Hello World')
hex_dig = hash_object.hexdigest()

Here is what the above code is Doing:
1. We import the hashlib library.
2. We create a variable named hash_object.
3. We use the hashlib.sha256() function to create a SHA-256 hash object.
4. We use the .update() function to pass the string ‘Hello World’ into the hash object.
5. We use the .hexdigest() function to return the hexadecimal representation of the hash object.
6. We print the value of the hex_dig variable.

Similar Posts