Add the action of encryption for the gamma cipher.
continuous-integration/drone/push Build is passing Details

dev
KKlochko 2 years ago
parent 53f89d4b4f
commit 4f89fede56

@ -1,7 +1,9 @@
(ns cipher-analytical-machine.cli.actions.cryptography (ns cipher-analytical-machine.cli.actions.cryptography
(:require (:require
[clojure.string :as cs]
[cipher-analytical-machine.ciphers.caesar :as caesar] [cipher-analytical-machine.ciphers.caesar :as caesar]
[cipher-analytical-machine.ciphers.simple-substitution :as ss] [cipher-analytical-machine.ciphers.simple-substitution :as ss]
[cipher-analytical-machine.ciphers.gamma :as gamma]
[cipher-analytical-machine.parsers.parsers :as ps] [cipher-analytical-machine.parsers.parsers :as ps]
[cipher-analytical-machine.parsers.simple-substitution :as pss]) [cipher-analytical-machine.parsers.simple-substitution :as pss])
(:gen-class)) (:gen-class))
@ -38,6 +40,17 @@
substitution-table (get data "table")] substitution-table (get data "table")]
(ss/decrypt-message-with-caesar message key substitution-table symbols))))) (ss/decrypt-message-with-caesar message key substitution-table symbols)))))
(defn gamma-actions
[options arguments action-type]
(let [message (:message options)
key (->> (cs/split (:key options) #",")
(map #(Integer/parseInt %)))
symbols (:symbols options)]
(cond
(= action-type :encrypt)
(gamma/encrypt-message key symbols message)
)))
(defn cryptography-actions (defn cryptography-actions
[options arguments action-type] [options arguments action-type]
(let [cipher (:cipher options)] (let [cipher (:cipher options)]
@ -46,5 +59,8 @@
(caesar-actions options arguments action-type) (caesar-actions options arguments action-type)
(= cipher "Simple substitution and Caesar") (= cipher "Simple substitution and Caesar")
(simple-substitution-with-caesar-actions options arguments action-type)))) (simple-substitution-with-caesar-actions options arguments action-type)
(= cipher "Gamma")
(gamma-actions options arguments action-type))))

Loading…
Cancel
Save