Add key validation for Caesar and Gamma ciphers.
continuous-integration/drone/push Build is passing Details

dev 0.9.6
KKlochko 2 years ago
parent 1e45771b3e
commit fcae272944

@ -1,5 +1,7 @@
(ns cipher-analytical-machine.cli.cli
(:require
[cipher-analytical-machine.parsers.parsers :as ps]
[cipher-analytical-machine.parsers.gamma :as gamma-ps]
[cipher-analytical-machine.cli.file :as file]
[cipher-analytical-machine.symbols.factories :as sf]
[cipher-analytical-machine.cli.options :as options]
@ -77,6 +79,15 @@
(or (contains? options :encrypt)
(contains? options :decrypt)))
(cond
(and (= (:cipher options) "Caesar")
(false? (ps/int-string? (:key options))))
{:exit-message (error-msg ["Please, use the key format: [+-](integer)!!! Example: 10, +9, -7."])}
(and (= (:cipher options) "Gamma")
(false? (gamma-ps/key? (:key options))))
{:exit-message (error-msg ["Please, use the key format: [+-](integer),[+-](integer),[+-](integer) !!! Example: 10,+9,-7."])}
(contains? options :encrypt)
{:options options :arguments arguments :action-type :encrypt}

Loading…
Cancel
Save