@ -2,7 +2,7 @@
( :require
[ clojure.test :refer :all ]
[ cipher-analytical-machine.analyzers.caesar :refer :all ]
[ cipher-analytical-machine.symbols.frequenc es :as sf ]
[ cipher-analytical-machine.symbols.frequenc i es :as sf ]
[ cipher-analytical-machine.analyzers.analyzers :as ca ]
[ clojure.string :as cs ] ) )
@ -25,9 +25,9 @@
( testing "There're 27 combinations for a 'Hello World'."
( let [ ciphertext "khoorczruog"
symbols "abcdefghijklmnopqrstuvwxyz "
frequenc es sf/english-letter-frequenc es
frequenc i es sf/english-letter-frequenc i es
text-pairs ( get-all-texts ciphertext symbols ) ]
( is ( = 27 ( count ( get-all-scores frequenc es text-pairs ) ) ) ) ) ) )
( is ( = 27 ( count ( get-all-scores frequenc i es text-pairs ) ) ) ) ) ) )
( deftest get-min-score-pair-test
( testing "If a key is one, then the min score pair is 15."
@ -40,47 +40,47 @@
ciphertext "khoorczruog"
key 3
symbols "abcdefghijklmnopqrstuvwxyz "
frequenc es sf/english-letter-frequenc es]
frequenc i es sf/english-letter-frequenc i es]
( testing "The plaintext is encrypted with 3 as the key."
( is ( = key ( get-key ciphertext symbols frequenc es) ) ) ) )
( is ( = key ( get-key ciphertext symbols frequenc i es) ) ) ) )
( let [ ; З поеми "Кавказ" Т а р а с а Григоровича Шевченка:
plaintext "Борітеся – поборете, Вам Бог помагає! З а вас правда, за вас слава. І воля святая!"
ciphertext "жхчощйшде–ецхжхчйщй,езєуежхиецхуєиєк!емєезєшецчєзїє,емєезєшештєзє.еоезхтдешздщєд!"
key 7
symbols "абвгґдеєжзиіїйклмнопрстуфхцчшщьюя "
frequenc es sf/ukrainian-letter-frequenc es]
frequenc i es sf/ukrainian-letter-frequenc i es]
( testing "The plaintext is encrypted with 3 as the key."
( is ( = key ( get-key ciphertext symbols frequenc es) ) ) ) ) )
( is ( = key ( get-key ciphertext symbols frequenc i es) ) ) ) ) )
( deftest get-plaintext-test
( let [ plaintext "hello world"
ciphertext "khoorczruog"
symbols "abcdefghijklmnopqrstuvwxyz "
frequenc es sf/english-letter-frequenc es]
frequenc i es sf/english-letter-frequenc i es]
( testing "The plaintext is encrypted with 3 as the key."
( is ( = plaintext ( get-plaintext ciphertext symbols frequenc es) ) ) )
( is ( = plaintext ( get-plaintext ciphertext symbols frequenc i es) ) ) )
( testing "The ciphertext is case-insensitive."
( is ( = plaintext ( get-plaintext "KhoorcZruog" symbols frequenc es) ) ) ) )
( is ( = plaintext ( get-plaintext "KhoorcZruog" symbols frequenc i es) ) ) ) )
( let [ ; З поеми "Кавказ" Т а р а с а Григоровича Шевченка:
plaintext "Борітеся – поборете, Вам Бог помагає! З а вас правда, за вас слава. І воля святая!"
ciphertext "жхчощйшде–ецхжхчйщй,езєуежхиецхуєиєк!емєезєшецчєзїє,емєезєшештєзє.еоезхтдешздщєд!"
key 7
symbols "абвгґдеєжзиіїйклмнопрстуфхцчшщьюя "
frequenc es sf/ukrainian-letter-frequenc es]
frequenc i es sf/ukrainian-letter-frequenc i es]
( testing "The ciphertext is case-insensitive."
( is ( = ( cs/lower-case plaintext )
( get-plaintext ciphertext symbols frequenc es) ) ) ) ) )
( get-plaintext ciphertext symbols frequenc i es) ) ) ) ) )
( deftest frequency-analizer-get-plaintext-test
( let [ plaintext "abc"
ciphertext "bca"
key 1
symbols "abc"
frequenc es sf/english-letter-frequenc es]
frequenc i es sf/english-letter-frequenc i es]
( testing "The ciphertext is 'bca' and key is 1."
( is ( = plaintext
( frequency-analizer-get-plaintext ciphertext symbols frequenc es) ) ) ) ) )
( frequency-analizer-get-plaintext ciphertext symbols frequenc i es) ) ) ) ) )