Vigenère cipher: Difference between revisions

Content deleted Content added
Line 960: Line 960:
(let ((text (strip text)) (key (strip key)) (i -1))
(let ((text (strip text)) (key (strip key)) (i -1))
(map 'string
(map 'string
(lambda (x)
(lambda (c)
(setf i (mod (1+ i) (length key)))
(setf i (mod (1+ i) (length key)))
(char +a+ (mod (+ (position x +a+) (* d (position (elt key i) +a+))) 26)))
(char +a+ (mod (+ (position c +a+) (* d (position (elt key i) +a+))) 26)))
text)))</lang>
text)))</lang>


2. Execution
2. Execution


{{out}}
<pre>(vigenere "« Through the Looking-Glass »" "Lewis Carroll")
<pre>(vigenere "« Through the Looking-Glass »" "Lewis Carroll")
(vigenere "ELNWMIHKYSWZZOEVYILRJG" "Lewis Carroll" :decode t)</pre>
{{out}}
<pre>
"ELNWMIHKYSWZZOEVYILRJG"
"ELNWMIHKYSWZZOEVYILRJG"
(vigenere "ELNWMIHKYSWZZOEVYILRJG" "Lewis Carroll" :decode t)
"THROUGHTHELOOKINGGLASS"</pre>
"THROUGHTHELOOKINGGLASS"</pre>