Add the analyzer options and their actions.
This commit is contained in:
@@ -132,14 +132,26 @@
|
|||||||
(save-output output options))
|
(save-output output options))
|
||||||
(println output))
|
(println output))
|
||||||
|
|
||||||
(defn cracking-actions
|
(defn cracking-caesar
|
||||||
[options arguments action-type]
|
[options arguments]
|
||||||
(let [message (:message options)
|
(let [analyzer (:analyzer options)
|
||||||
|
message (:message options)
|
||||||
symbols (:symbols options)
|
symbols (:symbols options)
|
||||||
frequencies symbol-frequencies/english-letter-frequencies]
|
frequencies symbol-frequencies/english-letter-frequencies]
|
||||||
(cond
|
(cond
|
||||||
(= action-type :cracking)
|
(= analyzer "Chi^2")
|
||||||
(caesar-analyzers/get-plaintext message symbols frequencies)
|
(caesar-analyzers/get-plaintext message symbols frequencies)
|
||||||
|
|
||||||
|
(= analyzer "Frequency")
|
||||||
|
(caesar-analyzers/frequency-analizer-get-plaintext message symbols
|
||||||
|
(symbol-frequencies/map-to-string frequencies)))))
|
||||||
|
|
||||||
|
(defn cracking-actions
|
||||||
|
[options arguments action-type]
|
||||||
|
(let [cipher (:cipher options)]
|
||||||
|
(cond
|
||||||
|
(= cipher "Caesar")
|
||||||
|
(cracking-caesar options arguments)
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(defn crypt-actions
|
(defn crypt-actions
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
(def default-cipher "Caesar")
|
(def default-cipher "Caesar")
|
||||||
|
|
||||||
|
(def analyzers-options
|
||||||
|
{"Caesar" #{"Chi^2" "Frequency"}})
|
||||||
|
|
||||||
(def language-options
|
(def language-options
|
||||||
#{"en", "uk"})
|
#{"en", "uk"})
|
||||||
|
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
["-l" "--language CODE" "The string will be used to set a default symbols for a cipher."
|
["-l" "--language CODE" "The string will be used to set a default symbols for a cipher."
|
||||||
:validate [#(contains? language-options %) "Must be a code from the list: en, uk!!!"]]
|
:validate [#(contains? language-options %) "Must be a code from the list: en, uk!!!"]]
|
||||||
["-C" "--cracking" "Cracking the encrypted message."]
|
["-C" "--cracking" "Cracking the encrypted message."]
|
||||||
|
["-a" "--analyzer ANALYZER" "The way of cracking."]
|
||||||
["-O" "--output-file OUTPUT-FILE" "Save the program output to a file."]
|
["-O" "--output-file OUTPUT-FILE" "Save the program output to a file."]
|
||||||
["-h" "--help"]])
|
["-h" "--help"]])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user