Add the clojure wrapper for the frequency analizer and its test.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-10-05 20:10:05 +03:00
parent 40af8401b2
commit 51609b1d27
2 changed files with 21 additions and 0 deletions
@@ -2,6 +2,8 @@
(:require [cipher-analytical-machine.caesar :as caesar]
[clojure.string :as cs]
[cipher-analytical-machine.cipher-analyzers :as ca])
(:import [cipher_analytical_machine.ciphers.caesar Decrypted]
[cipher_analytical_machine.analizers.caesar FrequencyAnalyzer])
(:gen-class))
(defn get-all-texts
@@ -46,3 +48,12 @@
(get-key ciphertext symbols letter-frequences)
symbols)))
(defn frequency-analizer-get-plaintext
"Return the plaintext from a ciphertext using simple analizer. The function is case-insensitive."
[ciphertext symbols letter-frequences]
(let [decrypt (reify Decrypted
(decrypt [this message key symbols]
(caesar/decrypt-message message key symbols)))]
(-> (new FrequencyAnalyzer ciphertext symbols letter-frequences decrypt)
.crack)))