Update the simple substitution cipher to split the decrypt-message.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -44,15 +44,26 @@
|
||||
(caesar/encrypt-message key symbols)
|
||||
(encrypt-message substitution-table)))
|
||||
|
||||
(defn decrypt-by-table
|
||||
"Decrypt a message by the substitution-table"
|
||||
[substitution-table message]
|
||||
(map (fn [char] (find-value-in-table char substitution-table)) message))
|
||||
|
||||
(defn decrypt-message-by-symbol-table
|
||||
"Decrypt a message using the simple substitution cipher. The function is case-insensitive. The substitution-table must be (symbols, symbols)."
|
||||
[substitution-table message ]
|
||||
(->> message
|
||||
(decrypt-by-table substitution-table)
|
||||
(remove nil?)
|
||||
(cs/join)))
|
||||
|
||||
(defn decrypt-message
|
||||
"Decrypt a message using the simple substitution cipher. The function is case-insensitive. The substitution-table must be "
|
||||
"Decrypt a message using the simple substitution cipher. The function is case-insensitive. The substitution-table must be (int, symbols)."
|
||||
[message substitution-table]
|
||||
(let [message (cs/split message #",")]
|
||||
(->> message
|
||||
(map #(Integer/parseInt %))
|
||||
(map (fn [char] (find-value-in-table char substitution-table)))
|
||||
(remove nil?)
|
||||
(cs/join))))
|
||||
(decrypt-message-by-symbol-table substitution-table))))
|
||||
|
||||
(defn decrypt-message-with-caesar
|
||||
"Decrypt a message using the simple substitution cipher and the Caesar cipher. The function is case-insensitive."
|
||||
|
||||
Reference in New Issue
Block a user