How to create a Hash calculator Using Python

Hash Calculater

Python Secret #Author: ManishHacker1

Hello guys, This is my new article about, how to create hash calculator with the help from hashlib module using Python. In my previous article, we were learned about cryptographic hashes. Now we will be make a hash calculator.

Requirement:

Python Installed in your Operating System.

Step:

In my code, first import

  • import hashlib
  • import sys
  • import optparse

where hashlib module for hashing algorithm sys module use for system fuction and last one, optparse module use for command line options.

Full Source Code


import hashlib
import sys
import optparse


parser = optparse.OptionParser()
parser.add_option('-n', '--name', dest='name', help='''Your Algo Name Options:
                                                    md5,sha1,sha224,sha256,sha384,sha512''')
parser.add_option('-k', '--key', dest='key', help='Your string key value')

(options, args) = parser.parse_args()


list = ['md5','sha1','sha224','sha384','sha512']

    
if options.name is None:
    options.name = raw_input('Please enter right Algo Name: ')
    if options.name in list:
        print 'Ok'
    else:
        print 'You are choose wrong Algo Name'
        sys.exit()
        
if options.key is None:
    options.key = raw_input('Enter Your Key Value: ')
        

select = options.name 
data = options.key 

h = hashlib.new(select)
h.update(data)
print 'Your ' + select + ' hash value: ',h.hexdigest()

In above code save as “anyname.py” where “.py” our file extension.

How to Use:

Step:

Open your command prompt and change your directory path where our hash_calculator.py is store.

After that, type in your command prompt:


python hash_calculator.py -h


Usage: Python hash_calculator1.py [options]

Options:
  -h, --help            show this help message and exit
  -n NAME, --name=NAME  Your Algo Name Options:
                        md5,sha1,sha224,sha256,sha384,sha512
  -k KEY, --key=KEY     Your string key value

Or you can direct use of this program. Write below command in your command prompt :

 python hash_calculator.py       and hit enter

After that enter your right algo name for example md5.
After that write your string value which you want to convert in md5 algorithm.

Thank You for reading this article. And like my FB page given below link and share it.

Best Python Training and Ethical Hacking Training in Meerut, Noida , Delhi.

Krypsec Digital Security Provided Python Training and Ethical Hacking Training

Source: Python Secret

Source: Python

Follow ManishHacker1

Summary
How to create Hash calculator Using Python
Article Name
How to create Hash calculator Using Python
Description
Hello guys, Today we will learn, how to create a hash calculator with the help from hashlib module using Python.
Author
Publisher Name
Kryptora
Publisher Logo

Leave a Reply

avatar
  Subscribe  
Notify of

Pin It on Pinterest

Optimization WordPress Plugins & Solutions by W3 EDGE