Esempio n. 1
0
	def test_decrypt(self):
		cipher = Transposition()
		open_text = normalize_text("Python is a general-purpose, interpreted high-level programming language")
		key = "password"
		cipher_text = cipher.encrypt(open_text, key)
		decrypted_text = cipher.decrypt(cipher_text, key)
		expected = open_text + "xx"
		self.assertEqual(decrypted_text, expected)
	def test_cs_crack(self):
		cipher = Vigenere()
		cracker = VigenereBruteForce()
		open_text = normalize_text("jasynpoklopurozzurendosilenstvivodarnusrovnamsezemijmenemmistrukanvodstvijamatkuvlastnivsakkdovizdaprokouknutoumelnikolivjakpribuznismrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnytedvidisotcecozzenstinytveuzralouzjetotadybratretyslezlzradcumdozadkujensedobrepodivejcostvojijimkouprovedlimusimedrzetpospoluatuznenimarnesnazenivejmenusatanarozpoutejmepeklouzsevmychpredstavachrodisedevyjevykrasnemodrenadrzecimtakrychlecernajinenitonahodouodpadnivodamrtverybynahazimedovodarenskychobjektuuznehodlamdalnaslouchattemvodarenskymblabolumsedekrysysezerouzbytkyvodarenskychkonstrukcipredpovidamvecnouskazuvodarenskemafiitakjakodavnopredcasemjsmesvatouchatrutopilystejnykonecpripravimepodvodnikumzvodarnynelzeveritnikomukdomatlamuplnoucistotyvsechnytyhlebestiecekavodazestokysmrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnyzevsechstrannavodarnusilaspinyutocizhorastavbydrtizeleznemepoklopydokristalovevodytecoucistirenskesplaskysabotaztospachanavejmenusedepravdy")
		key = "qwasd"
		cipher_text = cipher.encrypt(open_text, key)
		langmodel = LangModel(get_lang_path('cs'))
		cracked_key = cracker.crack(cipher_text, LanguageStats(langmodel))
		self.assertEqual(cracked_key, key)
Esempio n. 3
0
	def test_cs_crack(self):
		cipher = Caesar()
		cracker = CaesarBruteForce()
		open_text = normalize_text("Ja, Syn Poklopu, rozzuren do silenstvi, vodarnu srovnam se zemi, jmenem mistru kanvodstvi. Ja, matku vlastni, vsak kdo vi zda, prokouknutou mel, nikoliv jak pribuzni. ")
		key = "d"
		cipher_text = cipher.encrypt(open_text, key)
		langmodel = LangModel(get_lang_path('cs'))
		cracked_key = cracker.crack(cipher_text, LanguageStats(langmodel))
		self.assertEqual(cracked_key, key)	
Esempio n. 4
0
 def test_cs_crack(self):
     cipher = Caesar()
     cracker = TriangleAttack()
     open_text = normalize_text(
         "Ja, Syn Poklopu, rozzuren do silenstvi, vodarnu srovnam se zemi, jmenem mistru kanvodstvi. Ja, matku vlastni, vsak kdo vi zda, prokouknutou mel, nikoliv jak pribuzni. Tak jako davno pred casem jsme svatou chatru topily, stejny konec pripravime podvodnikum z vodarny. Nelze verit nikomu, kdo ma tlamu plnou cistoty. Vsechny tyhle bestie ceka voda ze stoky."
     )
     key = "q"
     cipher_text = cipher.encrypt(open_text, key)
     langmodel = LangModel(get_lang_path('cs'))
     cracked_key = cracker.crack(cipher_text, LanguageStats(langmodel))
     self.assertEqual(cracked_key, key)
 def test_cs_crack(self):
     cipher = Caesar()
     cracker = TriangleAttack()
     open_text = normalize_text(
         "Ja, Syn Poklopu, rozzuren do silenstvi, vodarnu srovnam se zemi, jmenem mistru kanvodstvi. Ja, matku vlastni, vsak kdo vi zda, prokouknutou mel, nikoliv jak pribuzni. Tak jako davno pred casem jsme svatou chatru topily, stejny konec pripravime podvodnikum z vodarny. Nelze verit nikomu, kdo ma tlamu plnou cistoty. Vsechny tyhle bestie ceka voda ze stoky."
     )
     key = "q"
     cipher_text = cipher.encrypt(open_text, key)
     langmodel = LangModel(get_lang_path("cs"))
     cracked_key = cracker.crack(cipher_text, LanguageStats(langmodel))
     self.assertEqual(cracked_key, key)
    def test_encrypt(self):
        cipher = Substitution()
        open_text = normalize_text("Python is a general-purpose, interpreted high-level programming language")
        cipher_text = cipher.encrypt(open_text, string.ascii_lowercase)
        self.assertEqual(cipher_text, open_text)

        cipher_text = cipher.encrypt(open_text, "camntwqzipryofxkhdlusbevjg")
        expected = "kjuzxfilcqtftdcyksdkxltifutdkdtutnziqzytbtykdxqdcooifqycfqscqt"
        self.assertEqual(cipher_text, expected)

        self.assertEqual(cipher.encrypt("", "a"), "")
	def test_encrypt(self):
		cipher = Caesar()
		open_text = normalize_text("Python is a general-purpose, interpreted high-level programming language")
		cipher_text = cipher.encrypt(open_text, "a")
		self.assertEqual(cipher_text, open_text)

		cipher_text = cipher.encrypt(open_text, "k")
		expected = "zidryxsckqoxobkvzebzycosxdobzbodonrsqrvofovzbyqbkwwsxqvkxqekqo"
		self.assertEqual(cipher_text, expected)

		self.assertEqual(cipher.encrypt("", "a"), "")
Esempio n. 8
0
 def test_cs_crack(self):
     cipher = Vigenere()
     cracker = VigenereBruteForce()
     open_text = normalize_text(
         "jasynpoklopurozzurendosilenstvivodarnusrovnamsezemijmenemmistrukanvodstvijamatkuvlastnivsakkdovizdaprokouknutoumelnikolivjakpribuznismrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnytedvidisotcecozzenstinytveuzralouzjetotadybratretyslezlzradcumdozadkujensedobrepodivejcostvojijimkouprovedlimusimedrzetpospoluatuznenimarnesnazenivejmenusatanarozpoutejmepeklouzsevmychpredstavachrodisedevyjevykrasnemodrenadrzecimtakrychlecernajinenitonahodouodpadnivodamrtverybynahazimedovodarenskychobjektuuznehodlamdalnaslouchattemvodarenskymblabolumsedekrysysezerouzbytkyvodarenskychkonstrukcipredpovidamvecnouskazuvodarenskemafiitakjakodavnopredcasemjsmesvatouchatrutopilystejnykonecpripravimepodvodnikumzvodarnynelzeveritnikomukdomatlamuplnoucistotyvsechnytyhlebestiecekavodazestokysmrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnyzevsechstrannavodarnusilaspinyutocizhorastavbydrtizeleznemepoklopydokristalovevodytecoucistirenskesplaskysabotaztospachanavejmenusedepravdy"
     )
     key = "qwasd"
     cipher_text = cipher.encrypt(open_text, key)
     langmodel = LangModel(get_lang_path('cs'))
     cracked_key = cracker.crack(cipher_text, LanguageStats(langmodel))
     self.assertEqual(cracked_key, key)
Esempio n. 9
0
    def test_encrypt(self):
        cipher = Caesar()
        open_text = normalize_text(
            "Python is a general-purpose, interpreted high-level programming language"
        )
        cipher_text = cipher.encrypt(open_text, "a")
        self.assertEqual(cipher_text, open_text)

        cipher_text = cipher.encrypt(open_text, "k")
        expected = "zidryxsckqoxobkvzebzycosxdobzbodonrsqrvofovzbyqbkwwsxqvkxqekqo"
        self.assertEqual(cipher_text, expected)

        self.assertEqual(cipher.encrypt("", "a"), "")
Esempio n. 10
0
    def test_encrypt(self):
        cipher = Substitution()
        open_text = normalize_text(
            "Python is a general-purpose, interpreted high-level programming language"
        )
        cipher_text = cipher.encrypt(open_text, string.ascii_lowercase)
        self.assertEqual(cipher_text, open_text)

        cipher_text = cipher.encrypt(open_text, "camntwqzipryofxkhdlusbevjg")
        expected = "kjuzxfilcqtftdcyksdkxltifutdkdtutnziqzytbtykdxqdcooifqycfqscqt"
        self.assertEqual(cipher_text, expected)

        self.assertEqual(cipher.encrypt("", "a"), "")
	def test_encrypt(self):
		cipher = Vigenere()
		open_text = normalize_text("Python is a general-purpose, interpreted high-level programming language")
		cipher_text = cipher.encrypt(open_text, "a")
		self.assertEqual(cipher_text, open_text)

		cipher_text = cipher.encrypt(open_text, "bc")
		expected = "qaujppjubifpftbnqwsrpufkovftqtfvffikhjmgwgmrsqhtbonkoimcoivchg"
		self.assertEqual(cipher_text, expected)

		cipher_text = cipher.encrypt(open_text, "password")
		expected = "eylzkbzvpgwfafroeujhkgvlctwjlfvwtdzacvchkedhncxupmeajucdcgmscs"
		self.assertEqual(cipher_text, expected)

		self.assertEqual(cipher.encrypt("", "a"), "")
	def setUp(self):
		self.cipher = Transposition()
		self.cracker = LongWordAttack()
		self.open_text = normalize_text("jajasynpoklopurozzuresndosilenstvivodarnusrovnamsezemijmenemmistrukanvodstvijamatkuvlastnivsakkdovizdaprokouknutoumelnikolivjakpribuznismrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnytedvidisotcecozzenstinytveuzralouzjetotadybratretyslezlzradcumdozadkujensedobrepodivejcostvojijimkouprovedlimusimedrzetpospoluatuznenimarnesnazenivejmenusatanarozpoutejmepeklouzsevmychpredstavachrodisedevyjevykrasnemodrenadrzecimtakrychlecernajinenitonahodouodpadnivodamrtverybynahazimedovodarenskychobjektuuznehodlamdalnaslouchattemvodarenskymblabolumsedekrysysezerouzbytkyvodarenskychkonstrukcipredpovidamvecnouskazuvodarenskemafiitakjakodavnopredcasemjsmesvatouchatrutopilystejnykonecpripravimepodvodnikumzvodarnynelzeveritnikomukdomatlamuplnoucistotyvsechnytyhlebestiecekavodazestokysmrtlidemzvodarnysmrtivrchnizradkynijenslavumistrumzcistirnyzevsechstrannavodarnusilaspinyutocizhorastavbydrtizeleznemepoklopydokristalovevodytecoucistirenskesplaskysabotaztospachanavejmenusedepravdy")
Esempio n. 13
0
	def test_encrypt(self):
		cipher = Transposition()
		open_text = normalize_text("Python is a general-purpose, interpreted high-level programming language")
		cipher_text = cipher.encrypt(open_text, "password")
		expected = "hnpripiapapnevannrsrhogeiaeelglxsliteraxterehlmuoeopgrngygutdemg"
		self.assertEqual(cipher_text, expected)