Created
July 20, 2017 08:07
-
-
Save jkotra/63569509e486d543915853c7eed84984 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3.5 | |
import argparse | |
import pickle | |
from simplecrypt import encrypt, decrypt | |
parser = argparse.ArgumentParser() | |
parser.add_argument("file", help="Input file to decrypt/encrypt", type=str) | |
args = parser.parse_args() | |
print(" _____ _ _ ___ ___ __ ") | |
print(" / ____| | | | | / _ \ / _ \/_ |") | |
print(" | (___ ___| | ___ __ ___| |_ _ __ ___ ___ __ _ __ _| | | | | | || |") | |
print(" \___ \ / _ \ |/ / '__/ _ \ __| '_ ` _ \/ __|/ _` | \ \ / / | | | | | || |") | |
print(" ____) | __/ <| | | __/ |_| | | | | \__ \ (_| | \ V /| |_| | |_| || |") | |
print(" |_____/ \___|_|\_\_| \___|\__|_| |_| |_|___/\__, | \_/ \___(_)___/ |_|") | |
print(" __/ | ") | |
print(" |___/ @jagadeesh_kotra ") | |
Main_Menu = input("What would you like to do?\n" | |
"1.Encrypt Message\n" | |
"2.Decrypt Message\n" | |
"3.About\n" | |
"Choose:") | |
print (Main_Menu) | |
if Main_Menu == "1": | |
try: | |
userpwd = input("Set your encryption password:") | |
f1 = open(args.file, 'rb') | |
except FileNotFoundError: | |
print("file not found!") | |
exit() | |
f1_read = f1.read() | |
f2_write = open('message.txt', 'wb') | |
ciphertext = encrypt(userpwd, f1_read) | |
pickle._dump(ciphertext, f2_write) | |
f1.close() | |
print("Encryption Completed.Data saved to " + args.file) | |
elif Main_Menu == "2": | |
try: | |
userpwd_decrypt = input("Enter your encryption password:") | |
f3 = open(args.file, "rb") | |
except FileNotFoundError: | |
print("file not found!") | |
f3_output = pickle.load(f3) | |
plaintext = decrypt(userpwd_decrypt, f3_output) | |
print(plaintext) | |
elif Main_Menu == "3": | |
print("coded with <3 by Jagadeesh Kotra") | |
print("[email protected]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment