Jump to content
Flubber

[Python] String to hash

Recommended Posts

Posted (edited)

# UPDATE [02.04.2010]:

[*] Am corectat output-ul care il face Python in "cmd" din Windows cand se alege optiunea de output "Bytes" (nu am stiut cum sa o numesc altfel), cu ajutorul lui cmiN -- multumesc frumos.

Pastebin url

#!/usr/bin/env;
# Coded by Flubber in Python 2.6.4;
[b][color=red]# *Update: 02.04.2010 - thanks to cmiN: fixed the output script to "bytes", now the script is displaying the "correct" octates.[/b][/color]
# Date: 09.03.2010; *02.04.2010
# Strings to hashes. Encryption supported in: MD5; SHA1; SHA224; SHA256; SHA384; SHA512.

print "\n[+] Starting up and configuring."
print "[+] Importing modules."
import time
from time import strftime
import hashlib

print "\n[+] Setting up 24h system clock."
timea = strftime("%a, %d %b %Y @ %H:%M:%S")
print "[+] " + timea + ":" + " All went OK. No errors."
print "[+] " + timea + ":" + " Printing my awes0me banner."
print ("""
\n|==========================|
| Today |
| I |
| Moo |
| |
| - "Moo!" |
|==========================|\n\n
""")
print "[+] " + timea + ":" + " Starting up."
time.sleep(2)
print "[+] " + timea + ":" + " Printing your encrypting options..."

option = raw_input("""
Encrypting options:
1: MD5;
2: SHA1;
3: SHA224;
4: SHA256;
5: SHA384;
6: SHA512.

If you want to exit press x or X and hit enter.
If you want to encrypt, please choose one option of the above [1,2,3,4,5,6]: """)

if option == '1':
h = hashlib.md5()
elif option == '2':
h = hashlib.sha1()
elif option == '3':
h = hashlib.sha224()
elif option == '4':
h = hashlib.sha256()
elif option == '5':
h = hashlib.sha384()
elif option == '6':
h = hashlib.sha512()
elif option == 'x' or option == 'X':
print "\n\n[+] " + timea + ":" + " Exiting. Have a nice day."
exit()
else:
print "\n[-] " + timea + ":" + " Oups, something went wrong."
print "[-] " + timea + ":" + " Exiting. Sorry!"
exit()

print "\n[+] " + timea + ":" + " OK, you chose option number: " + option + "."
hashy = raw_input("Enter your message to encrypt: ")
h.update(hashy)
print "\n\n[+] " + timea + ":" + " Encrypting, please wait..."
print "[+] " + timea + ":" + " Done."
print "[+] " + timea + ":" + " Printing your hash output options."


digesto = raw_input("""\n
Please choose your hash output:
1: "Bytes" (e.g. /x139/x26/x153/x83/x196/x97/x18/x150/x168/x39/x171/x248/x196/x120/x4/x215);
2: Hex (e.g. 8b1a9953c4611296a827abf8c47804d7).
Number: """)

[b][color=red]bytes = "/x" + "/x".join([str(ord(x)) for x in h.digest()])[/b][/color]
if digesto == '1':
print "\n[+] " + timea + ":" + " Your hash is: " + bytes + " ."
print "\n[+] " + timea + ":" + " Have a nice day!"
exit()
elif digesto == '2':
print "\n[+] " + timea + ":" + " Your hash is: " + str(h.hexdigest()) + " ."
print "\n[+] " + timea + ":" + " Have a nice day!"
exit()
else:
print "\n[-] " + timea + ":" + " Oups! Something went wrong."
print "[-] " + timea + ":" + " Exiting. Sorry!"
exit()

# OLD

OK, sunt incepator (nici macar atat, dar intelegeti ideea), nu va asteptati la cine stie ce script:

Pastebin url

#!/usr/bin/env;
# Coded by Flubber in Python 2.6;
# Date: 09.03.2010;
# Strings to hashes. Encryption supported in: MD5; SHA1; SHA224; SHA256; SHA384; SHA512.

print "\n[+] Starting up and configuring."
print "[+] Importing modules."
import time
from time import strftime
import hashlib

print "\n[+] Setting up 24h system clock."
timea = strftime("%a, %d %b %Y @ %H:%M:%S")
print "[+] " + timea + ":" + " All went OK. No errors."
print "[+] " + timea + ":" + " Printing my awes0me banner."
print ("""
\n|==========================|
| Today |
| I |
| Moo |
| |
| - "Moo!" |
|==========================|\n\n
""")
print "[+] " + timea + ":" + " Starting up."
time.sleep(2)
print "[+] " + timea + ":" + " Printing your encrypting options..."

option = raw_input("""
Encrypting options:
1: MD5;
2: SHA1;
3: SHA224;
4: SHA256;
5: SHA384;
6: SHA512.

If you want to exit press x or X and hit enter.
If you want to encrypt, please choose one option of the above [1,2,3,4,5,6]: """)

if option == '1':
h = hashlib.md5()
elif option == '2':
h = hashlib.sha1()
elif option == '3':
h = hashlib.sha224()
elif option == '4':
h = hashlib.sha256()
elif option == '5':
h = hashlib.sha384()
elif option == '6':
h = hashlib.sha512()
elif option == 'x' or option == 'X':
print "\n\n[+] " + timea + ":" + " Exiting. Have a nice day."
exit()
else:
print "\n[-] " + timea + ":" + " Oups, something went wrong."
print "[-] " + timea + ":" + " Exiting. Sorry!"
exit()

print "\n[+] " + timea + ":" + " OK, you chose option number: " + option + "."
hashy = raw_input("Enter your message to encrypt: ")
h.update(hashy)
print "\n\n[+] " + timea + ":" + " Encrypting, please wait..."
print "[+] " + timea + ":" + " Done."
print "[+] " + timea + ":" + " Printing your hash output options."


digesto = raw_input("""\n
Please choose your hash output:
1: Bytes;
2: Hex.
Number: """)

if digesto == '1':
print "\n[+] " + timea + ":" + " Your hash is: " + str(h.digest()) + " ."
print "\n[+] " + timea + ":" + " Have a nice day!"
exit()
elif digesto == '2':
print "\n[+] " + timea + ":" + " Your hash is: " + str(h.hexdigest()) + " ."
print "\n[+] " + timea + ":" + " Have a nice day!"
exit()
else:
print "\n[-] " + timea + ":" + " Oups! Something went wrong."
print "[-] " + timea + ":" + " Exiting. Sorry!"
exit()

Edited by Flubber
New update.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...