Generating an SHA 1/128/256 hash
SHA hashes are also extremely commonly used, alongside MD5 hashes. The early implementation of SHA hashes started with SHA1, which is less frequently used now due to the weakness of the hash. SHA1 was followed up with SHA128, which was then replaced by SHA256.
Getting ready
Once again for these scripts, we will only be requiring the hashlib
module.
How to do it…
Generating SHA hashes within Python is also extremely simple by using the imported module. With simple tweaks, we can change whether we would like to generate an SHA1, SHA128, or SHA256 hash.
The following are three different scripts that allow us to generate the different SHA hashes:
Here is the script of SHA1:
import hashlib message = raw_input("Enter the string you would like to hash: ") sha = hashlib.sha1(message) sha1 = sha.hexdigest() print sha1
Here is the script of SHA128:
import hashlib message = raw_input("Enter the string you would like to hash: ") sha = hashlib.sha128(message) sha128 = sha.hexdigest...