Substitution cipher: Difference between revisions
m
no edit summary
No edit summary |
mNo edit summary |
||
Line 1,175:
(alphabet-position))
(dotimes (i text-length)
(setq current-letter (substring text i (+ 1 i)))
(if (not (string-match-p "[a-zA-Z]" current-letter))
(setq coded-letter current-letter) ; pass the non-letter without change
(setq alphabet-position (string-match current-letter alphabet))
(setq coded-letter (substring code alphabet-position (+ 1 alphabet-position)))) ; AND pass the coded letter
(setq encoded-text (concat encoded-text coded-letter)))
encoded-text))
Line 1,194:
(code-position))
(dotimes (i text-length)
(setq current-letter (substring text i (+ 1 i))) ; find the next letter in TEXT
(if (not (string-match-p "[a-zA-Z]" current-letter)) ; IF it's not a letter
(setq uncoded-letter current-letter) ; pass the non-letter without change
(setq code-position (string-match current-letter code)) ; ELSE find where the letter is in CODE
(setq uncoded-letter (substring alphabet code-position (+ 1 code-position))))
(setq uncoded-text (concat uncoded-text uncoded-letter))) ; IN ANY CASE, add new letter to UNCODED-TEXT
uncoded-text))
|