Ejemplo n.º 1
0
    def test_decrypt(self):
        cipher = Caesar()
        cipher_text = "zidryxsckqoxobkvzebzycosxdobzbodonrsqrvofovzbyqbkwwsxqvkxqekqo"
        open_text = cipher.decrypt(cipher_text, "k")
        expected = "pythonisageneralpurposeinterpretedhighlevelprogramminglanguage"
        self.assertEqual(open_text, expected)

        self.assertEqual(cipher.decrypt("", "a"), "")
Ejemplo n.º 2
0
	def test_decrypt(self):
		cipher = Caesar()
		cipher_text = "zidryxsckqoxobkvzebzycosxdobzbodonrsqrvofovzbyqbkwwsxqvkxqekqo"
		open_text = cipher.decrypt(cipher_text, "k")
		expected = "pythonisageneralpurposeinterpretedhighlevelprogramminglanguage"
		self.assertEqual(open_text, expected)

		self.assertEqual(cipher.decrypt("", "a"), "")
Ejemplo n.º 3
0
class CaesarBruteForce(object):
	"""Cryptanalysis method for Caesar cipher"""
	def __init__(self):
		super(CaesarBruteForce, self).__init__()
		self.caesar = Caesar()
		
	def crack(self, cipher_text, langstats):
		key_text = ((k,self.caesar.decrypt(cipher_text, k)) for k in string.ascii_lowercase)
		return langstats.most_meaningful(key_text)
Ejemplo n.º 4
0
class CaesarBruteForce(object):
    """Cryptanalysis method for Caesar cipher"""
    def __init__(self):
        super(CaesarBruteForce, self).__init__()
        self.caesar = Caesar()

    def crack(self, cipher_text, langstats):
        key_text = ((k, self.caesar.decrypt(cipher_text, k))
                    for k in string.ascii_lowercase)
        return langstats.most_meaningful(key_text)