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 ...

Get Python Web Penetration Testing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.