Exemplo n.º 1
0
def main():
    s = Sender()
    r = Receiver()

    c = choose_cipher()
    if isinstance(c, RSA):
        s.set_cipher(c)
        r.set_cipher(c)
        operate_rsa(s, r)
    else:
        s.set_cipher(c)
        s.operate_cipher()
        print(s.get_encoded())

        r.set_cipher(c)
        r.set_key(s.get_key())
        r.set_encoded(s.get_encoded())

        r.operate_cipher()
        print(r.get_decoded())
        print(
            "**************************************************************************"
        )

        time.sleep(2)
        print("OH, NO!")
        time.sleep(0.5)
        print("A WILD HACKER APPEARED!!!")
        h = Hacker()
        h.set_key(s.get_key())
        time.sleep(1)
        print("Hacker found traces of a key...")
        h.set_encoded(s.get_encoded())
        time.sleep(1)
        print("Hacker found an encoded message...")
        h.set_dict(h.open_file())
        time.sleep(1)
        print("SHIT, he's started hacking!!!!!!")
        time.sleep(1)
        cracked = h.hack(h.encoded, s.get_cipher())
        if cracked:
            time.sleep(2)
            print("The hacker has successfully cracked your " + str(c) +
                  " cipher algorithm.\n\\end")
        else:
            time.sleep(2)
            print("You have successfully beaten the hacker!")
            time.sleep(1)
            print("Or maybe used some words not in the dictionary...")