Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/Chaocipher/Arc/chaocipher-1.arc
Normal file
35
Task/Chaocipher/Arc/chaocipher-1.arc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
(= lshift '((0 1) (2 14) (1 2) (14 26)))
|
||||
(= rshift '((1 3) (4 15) (3 4) (15 26) (0 1)))
|
||||
|
||||
(= rot (fn (alpha shift)
|
||||
(let shift (mod shift 26)
|
||||
(string (cut alpha shift) (cut alpha 0 shift)))))
|
||||
|
||||
(= scramble-wheel (fn (alpha moves)
|
||||
(= oput '())
|
||||
(up i 0 (- (len moves) 1)
|
||||
(push (cut alpha ((moves i) 0) ((moves i) 1)) oput))
|
||||
(= oput (string (rev oput)))))
|
||||
|
||||
(= chaocipher (fn (left right msg (o crypted) (o dec?))
|
||||
(unless crypted
|
||||
(prn "Encoding " msg " with chaocipher")
|
||||
(prn left " " right))
|
||||
(when dec? (swap left right))
|
||||
(= offset ((positions (msg 0) right) 0))
|
||||
(= left (rot left offset))
|
||||
(= right (rot right offset))
|
||||
(push (cut left 0 1) crypted)
|
||||
(when dec? (swap left right))
|
||||
(prn (scramble-wheel left lshift)
|
||||
" " (scramble-wheel right rshift))
|
||||
(if (> (len msg) 1)
|
||||
(chaocipher (scramble-wheel left lshift)
|
||||
(scramble-wheel right rshift)
|
||||
(cut msg 1) crypted dec?)
|
||||
(string (rev crypted)))))
|
||||
|
||||
(chaocipher "HXUCZVAMDSLKPEFJRIGTWOBNYQ" "PTLNBQDEOYSFAVZKGJRIHWXUMC"
|
||||
"WELLDONEISBETTERTHANWELLSAID")
|
||||
(chaocipher "HXUCZVAMDSLKPEFJRIGTWOBNYQ" "PTLNBQDEOYSFAVZKGJRIHWXUMC"
|
||||
"OAHQHCNYNXTSZJRRHJBYHQKSOUJY" nil 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue