From dd8084d7eb794c728a83fa4646a5982853bf7b0b Mon Sep 17 00:00:00 2001 From: panki27 Date: Tue, 24 Oct 2017 09:42:10 +0200 Subject: [PATCH] Added Base64 encoding and decoding --- crypttool.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crypttool.py b/crypttool.py index f03c7c4..ebed159 100644 --- a/crypttool.py +++ b/crypttool.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import sys, string, types, hashlib +import sys, string, types, hashlib, base64 LOWER_LETTERS = [chr(x) for x in range(97, 123)] UPPER_LETTERS = [chr(x) for x in range(65, 91)] @@ -60,6 +60,15 @@ def translate(inputString, inputType, outputType): elif(outputType == 5): result = chr(inputString) return result +def base64prompt(): + choice = raw_input('Would you like to [e]ncode or [d]ecode? ') + if (choice == 'e'): + inputString = raw_input("String to encode: ") + print(base64.b64encode(inputString)) + else: + inputString = raw_input("String to decode: ") + print(base64.b64decode(inputString)) + def rotPrompt(): choice = input("What kind of ROT do you want to perform? 1-25, or all: ") @@ -115,6 +124,7 @@ print("How may we serve you today?") print("1: ROT/Ceasar Encryption") print("2: Hashing functions") print("3: Translation") +print("4: Base64 Encoder/Decoder") choice = input("Please make a selection: ") @@ -124,5 +134,7 @@ elif (choice == 2): hashPrompt() elif (choice == 3): translatePrompt() +elif(choice == 4): + base64prompt() print("Thank you for flying with PankiCrypt Airlines!")