Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !#/usr/bin/python
- # Hey, Feel free to scrap, edit, and do whatever you wish to this code
- # All I ask is that you give me some credit if you decide to go public.
- print("Welcome to Syntax's multitool!\n")
- print("1: Cipher")
- print("2: Hash")
- print("3: Calculator")
- select = raw_input("Please make a selection based on the number associated: ")
- if select == "1":
- print("1: AES")
- print("2: Blowfish")
- print("3: DES")
- print("4: Base64")
- print("5: CAST")
- select = raw_input("Please make a selection based on the number associated: ")
- if select == "1":
- from Crypto.Cipher import AES
- from Crypto import Random
- key = b'Sixteen byte key'
- iv = Random.new().read(AES.block_size)
- cipher = AES.new(key, AES.MODE_CFB, iv)
- raw_msg = raw_input("Please enter the string you would like to encrypt: ")
- msg = iv + cipher.encrypt(b"'" + raw_msg + "'")
- print("Your output is: " + msg)
- elif select == "2":
- from Crypto.Cipher import Blowfish
- from Crypto import Random
- from struct import pack
- import base64
- bs = Blowfish.block_size
- raw_key = raw_input("Please enter your arbitrarily long encryption key: ")
- key = b"'" + raw_key + "'"
- iv = Random.new().read(bs)
- cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
- plaintext = raw_input("Please enter the string you would like to encrypt: ")
- plaintext0 = b"'" + plaintext + "'"
- plen = bs - divmod(len(plaintext),bs)[1]
- padding = [plen]*plen
- padding = pack('b'*plen, *padding)
- msg = iv + cipher.encrypt(plaintext0 + padding)
- encoded = base64.b64encode(msg)
- print("Your output is: " + msg)
- print("Your output encoded with base64 is: " + encoded)
- elif select == "3":
- from Crypto.Cipher import DES
- from Crypto import Random
- from Crypto.Util import Counter
- raw_key = raw_input("Please enter your sixteen byte encryption key: ")
- key = b"'" + raw_key + "'"
- nonce = Random.new().read(DES.block_size/2)
- ctr = Counter.new(DES.block_size*8/2, prefix=nonce)
- cipher = DES.new(key, DES.MODE_CTR, counter=ctr)
- plaintext = raw_input("Please enter the string you would like to encrypt: ")
- plaintext0 = b"'" + plaintext + "'"
- msg = nonce + cipher.encrypt(plaintext0)
- print("Your output is:" + msg)
- elif select == "4":
- import base64
- print("1: Encryption")
- print("2: Decryption")
- select = raw_input("Please make a selection based on the number associated: ")
- if select == "1":
- msg = raw_input("Please enter the string you would like to encrypt: ")
- encode = base64.b64encode(msg)
- elif select == "2":
- msg = raw_input("Please enter the encrypted string you would like to decrypt: ")
- decode = base64.b64decode(msg)
- else:
- print("Please choose a real option...")
- elif select == "5":
- from Crypto.Cipher import CAST
- from Crypto import Random
- import base64
- print("1: Encryption")
- print("2: Decryption")
- select = raw_input("Please enter your selection based on the number associated: ")
- if select == "1":
- key = b'Sixteen byte key'
- iv = Random.new().read(CAST.block_size)
- cipher = CAST.new(key, CAST.MODE_OPENPGP, iv)
- plaintext0 = raw_input("Please enter the string you wish to encrypt: ")
- plaintext1 = b"'" + plaintext0 + "'"
- msg = cipher.encrypt(plaintext1)
- encode = base64.b64encode(msg)
- print("Your output encoded with base64 is: " + encode)
- elif select == "2":
- encoded = raw_input("Please enter your encoded string: ")
- decode = base64.b64decode(encoded)
- key = b'Sixteen byte key'
- iv = Random.new().read(CAST.block_size)
- cipher = CAST.new(key, CAST.MODE_OPENPGP, iv)
- plaintext1 = b"'" + decode + "'"
- msg = cipher.encrypt(plaintext1)
- eiv = msg[:CAST.block_size+2]
- ciphertext = msg[CAST.block_size+2:]
- cipher = CAST.new(key, CAST.MODE_OPENPGP, eiv)
- decrypt = cipher.decrypt(ciphertext)
- print(decrypt)
- else:
- print("Please choose a real option...")
- else:
- print("Please enter a real option...")
- elif select == "2":
- print("1: MD4")
- print("2: MD5")
- print("3: SHA")
- print("4: SHA512")
- select = raw_input("Please make your selection based on the number associated: ")
- if select == "1":
- from Crypto.Hash import MD4
- h = MD4.new()
- hash = raw_input("Please enter ther string you would like to hash: ")
- h.update(b"'" + hash + "'")
- print(h.hexdigest())
- elif select == "2":
- from Crypto.Hash import MD5
- h = MD5.new()
- hash = raw_input("Please enter ther string you would like to hash: ")
- h.update(b"'" + hash + "'")
- print(h.hexdigest())
- elif select == "3":
- from Crypto.Hash import SHA
- h = SHA.new()
- hash = raw_input("Please enter ther string you would like to hash: ")
- h.update(b"'" + hash + "'")
- print(h.hexdigest())
- elif select == "4":
- from Crypto.Hash import SHA512
- h = SHA512.new()
- hash = raw_input("Please enter ther string you would like to hash: ")
- h.update(b"'" + hash + "'")
- print(h.hexdigest())
- else:
- print("Please enter a real option...")
- elif select == "3":
- def get_float(prompt):
- while True:
- try:
- return float(raw_input(prompt))
- except ValueError, e:
- print "Invalid input"
- print("1: ADDITION")
- print("2: SUBTRACTION")
- print("3: MULTIPLICATION")
- print("4: DIVISION")
- CHOICE = raw_input("Enter the Numbers:")
- if CHOICE == "1":
- a = get_float("Enter the value of a: ")
- b = get_float("Enter the value of b: ")
- c = a + b
- print(c)
- elif CHOICE == "2":
- a = get_float("Enter the value of a: ")
- b = get_float("Enter the value of b: ")
- c = a - b
- print(c)
- elif CHOICE == "3":
- a = get_float("Enter the value of a: ")
- b = get_float("Enter the value of b: ")
- c = a * b
- print(c)
- elif CHOICE == "4":
- a = get_float("Enter the value of a: ")
- b = get_float("Enter the value of b: ")
- c = a / b
- print(c)
- else:
- print "Invalid Number"
- print "\n"
- else:
- print("Please enter a real option...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement