Add the clojure wrapper for the frequency analizer and its test.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user