Ejemplo n.º 1
0
        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()
Ejemplo n.º 2
0
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***")
Ejemplo n.º 4
0
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())
Ejemplo n.º 5
0
from EBox import *

ebox = EBox()
ebox.set_password("CATZ");
x = ebox.encrypt("dig trenches at dawn")
print(x)

#  expected output:
#  FIZITE61JEBZVDTLP
Ejemplo n.º 6
0
from EBox import *

ebox = EBox()
ebox.reset("decrypt", 1)
ebox.set_password("CATZ")
x = ebox.decrypt("FIZITE61JEBZVDTLPT7ITIV9VHX3PE5N")
print(x)

#  expected output:
#  DIGTRENCHESATDAWNTOTRICKTHEENEMY
Ejemplo n.º 7
0
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