Bacon cipher: Difference between revisions

m
Line 1,023:
2. Program
 
<lang lisp>;; 22.06.1415
 
(defconstant +codes+
Line 1,048:
(setf code (cdr code)))
(setf cipher (append cipher (list c))))
(return-from encode (coerce cipher 'string)))))
 
(defun decode (text)
Line 1,060:
(setf key (append key (list (car (rassoc code +codes+ :test #'equal)))))
(setf code nil)))
(return-from decode (coerce key 'string))))</lang>
 
3. Example
 
<lang lisp>(defconstant +monologue-plaintext+ (concatenate 'string
"I've known adventures, seen places you people will never see, I've been Offw"
"orld and back... frontiers ! I've stood on the back deck of a blinker bound "
Line 1,072:
"en it, felt it..."))
 
(defconstant +monologue-ciphertextkey+ (concatenate 'string
Tearstears in rain »")</lang>
"I'VE knOwn ADveNtures, seEn plACes YoU PEoplE will NEvER SEe, i'Ve beEn offw"
"oRld anD BaCK... FRon"))
 
(defconstant +monologue-key+
"« Tears in rain »")</lang>
 
4. Execution
 
{{out}}
<pre>(encode +monologue-plaintext+ +monologue-key+)
"I'VE knOwn ADveNtures, seEn plACes YoU PEoplE will NEvER SEe, i'Ve beEn offwoRl
d anD BaCK... FRon"
(decode (encode +monologue-ciphertext+ +key+)
" tears in rain "</pre>
 
422

edits