コード例 #1
0
ファイル: test_vigner.py プロジェクト: sbogutyn/krypto
	def test_znajdz_klucz(self):
		tekst_do_zaszyfrowania = """
		The idea behind the Vigenère cipher, like all polyalphabetic ciphers, is to disguise plaintext letter frequencies,
		which interferes with a straightforward application of frequency analysis. For instance, if P is the most frequent
		letter in a ciphertext whose plaintext is in English, one might suspect that P corresponds to E, because E is the most
		frequently used letter in English. However, using the Vigenère cipher, E can be enciphered as different ciphertext letters
		at different points in the message, thus defeating simple frequency analysis. The primary weakness of the Vigenère cipher
		is the repeating nature of its key. If a cryptanalyst correctly guesses the key's length, then the cipher text can be
		treated as interwoven Caesar ciphers, which individually are easily broken. The Kasiski and Friedman tests can help determine the key length.
		"""
		zaszyfrowany_tekst = vigner.zaszyfruj_tekst(vigner.przygotuj_tekst(tekst_do_zaszyfrowania), "secret")
		dlugosc_klucza = 6
		self.assertEqual(vigner.znajdz_klucz(zaszyfrowany_tekst, dlugosc_klucza), "secret")
コード例 #2
0
ファイル: test_vigner.py プロジェクト: sbogutyn/krypto
	def test_zaszyfruj_tekst(self):
		klucz = "secret"
		tekst = "namete"
		oczekiwany_wynik = "feovxx"
		self.assertEqual(oczekiwany_wynik, vigner.zaszyfruj_tekst(tekst, klucz))