Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Vigen-re-cipher/Racket/vigen-re-cipher-1.rkt
Normal file
21
Task/Vigen-re-cipher/Racket/vigen-re-cipher-1.rkt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#lang racket
|
||||
(define chr integer->char)
|
||||
(define ord char->integer)
|
||||
|
||||
(define (encrypt msg key)
|
||||
(define cleaned
|
||||
(list->string
|
||||
(for/list ([c (string-upcase msg)]
|
||||
#:when (char-alphabetic? c)) c)))
|
||||
(list->string
|
||||
(for/list ([c cleaned] [k (in-cycle key)])
|
||||
(chr (+ (modulo (+ (ord c) (ord k)) 26) (ord #\A))))))
|
||||
|
||||
(define (decrypt msg key)
|
||||
(list->string
|
||||
(for/list ([c msg] [k (in-cycle key)])
|
||||
(chr (+ (modulo (- (ord c) (ord k)) 26) (ord #\A))))))
|
||||
|
||||
(decrypt (encrypt "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!"
|
||||
"VIGENERECIPHER")
|
||||
"VIGENERECIPHER")
|
||||
1
Task/Vigen-re-cipher/Racket/vigen-re-cipher-2.rkt
Normal file
1
Task/Vigen-re-cipher/Racket/vigen-re-cipher-2.rkt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"BEWARETHEJABBERWOCKMYSONTHEJAWSTHATBITETHECLAWSTHATCATCH"
|
||||
Loading…
Add table
Add a link
Reference in a new issue