Implementing SHA and MD5 hashes together

In this section, we will see how SHA and MD5 hash work together.

Getting ready

For the following script, we will only require the hashlib module.

How to do it…

We are going to tie everything previously done together to form one big script. This will output three versions of SHA hashes and also an MD5 hash, so the user can choose which one they would like to use:

import hashlib message = raw_input("Enter the string you would like to hash: ") md5 = hashlib.md5(message) md5 = md5.hexdigest() sha1 = hashlib.sha1(message) sha1 = sha1.hexdigest() sha256 = hashlib.sha256(message) sha256 = sha256.hexdigest() sha512 = hashlib.sha512(message) sha512 = sha512.hexdigest() print "MD5 Hash =", md5 print "SHA1 Hash =", sha1 ...

Get Python: Penetration Testing for Developers 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.