Add the analyzer options and their actions.
This commit is contained in:
@@ -132,14 +132,26 @@
|
||||
(save-output output options))
|
||||
(println output))
|
||||
|
||||
(defn cracking-actions
|
||||
[options arguments action-type]
|
||||
(let [message (:message options)
|
||||
(defn cracking-caesar
|
||||
[options arguments]
|
||||
(let [analyzer (:analyzer options)
|
||||
message (:message options)
|
||||
symbols (:symbols options)
|
||||
frequencies symbol-frequencies/english-letter-frequencies]
|
||||
(cond
|
||||
(= action-type :cracking)
|
||||
(= analyzer "Chi^2")
|
||||
(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
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
(def default-cipher "Caesar")
|
||||
|
||||
(def analyzers-options
|
||||
{"Caesar" #{"Chi^2" "Frequency"}})
|
||||
|
||||
(def language-options
|
||||
#{"en", "uk"})
|
||||
|
||||
@@ -28,6 +31,7 @@
|
||||
["-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!!!"]]
|
||||
["-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."]
|
||||
["-h" "--help"]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user