def db_setter(text, key):

	global x1

	global x2

	x1 = caesar.encode(text,key)

	x2 = caesar.decode(x1,key)
	def test_encode(self):

		self.assertEqual(caesar.encode("abcd", -1), "zabc")
		self.assertEqual(caesar.encode("abcd", 1), "bcde")
		self.assertEqual(caesar.encode("nothing", -999), "cdiwxcv")	
		self.assertEqual(caesar.encode("nothing", 999), "yzestyr")
		self.assertEqual(caesar.encode("anything", 26), "anything")
		self.assertEqual(caesar.encode("anything", -26), "anything")
Beispiel #3
0
def send(event=None):  # event is passed by binders.
    """Handles sending of messages."""
    msg = my_msg.get()
    quit_msg = msg
    global is_name

    if not is_name:
        msg = caesar.encode(msg, 3)
        print(msg)
        msg = rle.compress(msg)
        print(msg)
    else:
        is_name = False
    my_msg.set("")  # Clears input field.
    client_socket.send(bytes(msg, "utf8"))
    if quit_msg == "{quit}":
        client_socket.close()
        top.quit()
Beispiel #4
0
 def test_encode_right_shift(self):
     expected = "yZa_VwX"
     actual = caesar.encode("aBc_XyZ", -2)
     self.assertEquals(expected, actual)
Beispiel #5
0
 def test_encode_right_shift(self):
     expected = "CdEfG_hIjAb"
     actual = caesar.encode("AbCdE_fGhXz", 2)
     self.assertEquals(expected, actual)
Beispiel #6
0
import caesar

text = "treffenmittwochneunuhrbahnhoffriedrichstrasse"
key = "plan"

encrypted = ""

for i, c in enumerate(text):
    if i < len(key):
        k = key[i]
    else:
        k = text[i - len(key)]
    e = caesar.encode(c, ord(k) - ord("a"), True)
    encrypted += e
    print("%c & %c & %c \\\\" % (c, k, e))

print(encrypted)
Beispiel #7
0
	def test_encode_invalid(self):
		self.assertEqual(encode('Google forever', 30), 'Invalid key!')
		self.assertEqual(encode('Google forever', 0), 'Invalid key!')
Beispiel #8
0
	def test_encode_valid(self):
		self.assertEqual(encode('Google forever', 5), 'Gttlqj ktwjajw')
"""

import caesar
import rot13
import trithemius
import vigenere

print("""
 -----------------------------------------------------
| CLASSICAL CRYPTOGRAPHY EXAMPLES (ENCODED & DECODED) |
 -----------------------------------------------------
""")

print("[ CAESAR CIPHER ]")
caesar_msg = "This method was used by Julius Caesar in his personal correspondence, hence it being named after him."
caesar_msg_enc = caesar.encode(caesar_msg, 7)
print("Cipher    >>", caesar_msg_enc)
caesar_msg_dec = caesar.decode(caesar_msg_enc, 7)
print("Plaintext >>", caesar_msg_dec)
print("About: https://en.wikipedia.org/wiki/Caesar_cipher", "\n")

print("[ROT13 CIPHER]")
rot13_msg = "This cipher is a variant of the Caesar Cipher in which each letter is replaced with the thirteenth letter after (or before) it. The process for encoding and decoding is exactly the same."
rot13_msg_enc = rot13.encode(rot13_msg)
print("Cipher    >>", rot13_msg_enc)
rot13_msg_dec = rot13.decode(rot13_msg_enc)
print("Plaintext >>", rot13_msg_dec)
print("About: https://en.wikipedia.org/wiki/ROT13", "\n")

print("[TRITHEMIUS CIPHER]")
trith_msg = "The Trithemius Cipher was invented by Johannes Trithemius and was outlined in his book Polygraphia, which is often considered the first published work on cryptology."