Bacon cipher: Difference between revisions
m
→Association tables
Cyril Nocton (talk | contribs) |
Cyril Nocton (talk | contribs) |
||
Line 1,013:
1. Note
<pre>#\x -> assoc ->
For instance.
<pre>(cdr (assoc #\a +
2. Program
Line 1,025:
<lang lisp>;; 22.06.14
(defconstant +
'((#\a . (A A A A A)) (#\b . (A A A A B)) (#\c . (A A A B A))
(#\d . (A A A B B)) (#\e . (A A B A A)) (#\f . (A A B A B))
Line 1,036:
(#\y . (B B A A A)) (#\z . (B B A A B)) (#\space . (B B B A A))))
(defun encode (
(let (cipher
(setf msg (string-downcase
(loop for c across
(setf
(setf
(loop for c across
(when (alpha-char-p c)
(when (eq (car
(setf c (char-upcase c)))
(setf
(setf cipher (append cipher (list c))))
(return-from encode (coerce cipher 'string)))))
(defun decode (
(let (key
(setf
(loop for c across
(if (lower-case-p c)
(setf
(setf mask (append
(when (= (length
(setf key (append key (list (car (rassoc
(setf
(return-from decode (coerce key 'string))))</lang>
|