if filename.endswith("-encrypted.txt"): newfilename = filename[0:-14] + "-decrypted.txt" else: newfilename = filename[0:-4] + "-dcrypted.txt" with open(filename) as f: text = f.read() fnew = open(newfilename, "w") for line in text.split("\n"): encline = ebox.decrypt(line) fnew.write(encline) fnew.close() password = "" #input("Enter your password:"******"encrypt" level = 0 while (True): try: line = input("? ") if line == "quit": break if line.startswith("e "): if ebox.algorithm == "Viginere": if password == "": password = input("Enter your password:") ebox.set_password(password) print(ebox.encrypt(line[2:])) else: ebox.runEncrypt()
from EBox import * ebox = EBox() ebox.reset("decrypt", 1) ebox.set_password("CATZ") expect = "DIGTRENCHESATDAWNTOTRICKTHEENEMY" print("Expect: " + expect) x = ebox.decrypt("FIZIUF72LGD1YGWOTXBMYN0E1N39WLCU") print("Actual: " + x) if (expect == x): print("***PASSED***") print("") print(" (the faulty algorithm) ") print("Expect: " + "DIGTRENCHESATDAWNTOTRICKTHEENEMY") x = ebox.decrypt("FIZITE61JEBZVDTLPT7ITIV9VHX3PE5N") print("Actual: " + x) if (expect == x): print("***PASSED***")
from EBox import * ebox = EBox() ebox.reset("encrypt", 1) ebox.set_password("CATZ") expect = "FIZIUF72LGD1YGWOTXBMYN0E1N39WLCU" print("Expect: " + expect) x = ebox.encrypt("dig trenches at dawn to trick the enemy") print("Actual: " + x) if (expect == x): print("***PASSED***") print("") print(" (the faulty algorithm) ") expect = "FIZITE61JEBZVDTLPT7ITIV9VHX3PE5N" print("Expect: " + expect) x = ebox.encrypt("dig trenches at dawn to trick the enemy") print("Actual: " + x) if (expect == x): print("***PASSED***")
from EBox import * ebox = EBox() ebox.reset("encrypt", 0) ebox.set_password("CATZ") x = ebox.encrypt("dig trenches at dawn") print(x) print(ebox.get_status()) x = ebox.encrypt("the cat yawned at dawn and then slept the rest of the day") print(x) print(ebox.get_status())
from EBox import * ebox = EBox() ebox.set_password("CATZ"); x = ebox.encrypt("dig trenches at dawn") print(x) # expected output: # FIZITE61JEBZVDTLP
from EBox import * ebox = EBox() ebox.reset("decrypt", 1) ebox.set_password("CATZ") x = ebox.decrypt("FIZITE61JEBZVDTLPT7ITIV9VHX3PE5N") print(x) # expected output: # DIGTRENCHESATDAWNTOTRICKTHEENEMY
from EBox import * ebox = EBox() ebox.reset("decrypt", 0) ebox.set_password("CATZ") x = ebox.decrypt("FIZITE61JEBZVDTLP") print(x) # expected output: # DIG TRENCHES AT DAWN