This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
(:require
|
||||
[cipher-analytical-machine.file :as file]
|
||||
[cipher-analytical-machine.caesar :as caesar]
|
||||
[cipher-analytical-machine.caesar-analyzers :as caesar-analyzers]
|
||||
[cipher-analytical-machine.symbol-factories :as sf]
|
||||
[cipher-analytical-machine.symbol-frequences :as symbol-frequences]
|
||||
[clojure.string :as cs]
|
||||
[clojure.tools.cli :refer [parse-opts]])
|
||||
(:gen-class))
|
||||
@@ -20,6 +22,7 @@
|
||||
["-d" "--decrypt" "Decrypt the message."]
|
||||
["-s" "--symbols" "The string will be used as a set of symbols for a cipher."
|
||||
:default (sf/default-symbol-factory "en")]
|
||||
["-C" "--cracking" "Cracking the encrypted message."]
|
||||
["-h" "--help"]])
|
||||
|
||||
(defn usage [options-summary]
|
||||
@@ -72,6 +75,11 @@
|
||||
(contains? options :decrypt)
|
||||
{:options options :arguments arguments :action-type :decrypt})
|
||||
|
||||
(and (map-has-keys? options [:cipher, :cracking])
|
||||
(or (contains? options :message)
|
||||
(contains? options :message-file)))
|
||||
{:options options :arguments arguments :action-type :cracking}
|
||||
|
||||
:else
|
||||
{:exit-message (usage summary)})))
|
||||
|
||||
@@ -97,6 +105,9 @@
|
||||
symbols (:symbols options)]
|
||||
(println
|
||||
(cond
|
||||
(= action-type :cracking)
|
||||
(caesar-analyzers/get-plaintext message symbols symbol-frequences/english-letter-frequences)
|
||||
|
||||
(= action-type :encrypt)
|
||||
(caesar/encrypt-message message key symbols)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user