Vigenère cipher: Difference between revisions

m
Line 960:
(let ((text (strip text)) (key (strip key)) (i -1))
(map 'string
(lambda (xc)
(setf i (mod (1+ i) (length key)))
(char +a+ (mod (+ (position xc +a+) (* d (position (elt key i) +a+))) 26)))
text)))</lang>
 
2. Execution
 
{{out}}
<pre>(vigenere "« Through the Looking-Glass »" "Lewis Carroll")
(vigenere "ELNWMIHKYSWZZOEVYILRJG" "Lewis Carroll" :decode t)</pre>
{{out}}
<pre>
"ELNWMIHKYSWZZOEVYILRJG"
(vigenere "ELNWMIHKYSWZZOEVYILRJG" "Lewis Carroll" :decode t)
"THROUGHTHELOOKINGGLASS"</pre>
 
422

edits