|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import hashlib |
| 4 | +from optparse import * |
| 5 | + |
| 6 | + |
| 7 | +class colors: |
| 8 | + def __init__(self): |
| 9 | + self.blue = "\033[94m" |
| 10 | + self.red = "\033[91m" |
| 11 | + self.end = "\033[0m" |
| 12 | +cl = colors() |
| 13 | + |
| 14 | +print(cl.blue+""" |
| 15 | +
|
| 16 | + *--------------------------------------* |
| 17 | + | programmed by : mohamed | |
| 18 | + | fb.me/hack1lab | |
| 19 | + *--------------------------------------* |
| 20 | + _ _ _ _ |
| 21 | + | |__ __ _ ___| | _| | __ _| |__ |
| 22 | + | '_ \ / _` |/ __| |/ / |/ _` | '_ \ |
| 23 | + | | | | (_| | (__| <| | (_| | |_) | |
| 24 | + |_| |_|\__,_|\___|_|\_\_|\__,_|_.__/ |
| 25 | + |
| 26 | + hashing |
| 27 | + --------- |
| 28 | +
|
| 29 | +"""+cl.end) |
| 30 | + |
| 31 | +def hashing(data, type_h): |
| 32 | + hash_type = hashlib.new(type_h) |
| 33 | + hash_type.update(data) |
| 34 | + return hash_type.hexdigest() |
| 35 | + |
| 36 | +parser = OptionParser(""" |
| 37 | +
|
| 38 | +-------------------------[Usage]------------------------ |
| 39 | +
|
| 40 | +#Options: |
| 41 | + |
| 42 | + -x hashing text |
| 43 | + -f hashing file any file e.g (.txt, .rar, .zip, .iso, .exe, .py, ........ etc) |
| 44 | + -t the Hashing type e.g (md5, md4, sha1, sha256, sha512, ....... etc) |
| 45 | + |
| 46 | +#Example: |
| 47 | +
|
| 48 | + python hashing.py -x hacklab -t md5 |
| 49 | +
|
| 50 | + python hashing.py -f kali_linux.iso -t sha1 |
| 51 | +
|
| 52 | + """) |
| 53 | +try: |
| 54 | + parser.add_option("-x",dest="Text",type="string", help="enter text for hashing") |
| 55 | + parser.add_option("-f",dest="File",type="string", help="enter file for hahsing") |
| 56 | + parser.add_option("-t",dest="Type",type="string", help="Enter the Hashing type") |
| 57 | + (options, args) = parser.parse_args() |
| 58 | + if options.Text == None and options.File == None: |
| 59 | + print(cl.blue+parser.usage+cl.end) |
| 60 | + exit(0) |
| 61 | + else: |
| 62 | + Text = str(options.Text) |
| 63 | + File = str(options.File) |
| 64 | + Type = str(options.Type) |
| 65 | + if options.Text == None: |
| 66 | + read_file = open(File, 'r') |
| 67 | + File = str(read_file.read()) |
| 68 | + result = hashing(File, Type) |
| 69 | + print(cl.red+"[+] Hash File: [ "+result+' ]'+cl.end+'\n') |
| 70 | + elif options.File == None: |
| 71 | + result = hashing(Text,Type) |
| 72 | + print(cl.red+"[+] Hash Text: [ "+result+' ]'+cl.end+'\n') |
| 73 | + else: |
| 74 | + print(cl.blue+"[-] there error !!"+cl.end) |
| 75 | +except Exception, e: |
| 76 | + print("Error: "+ str(e)) |
0 commit comments