#lang racket
(require (only-in srfi/13 string-map))
(define (rotate text shift)
(string-map (lambda (ch)
(let ((ch (if (char-lower-case? ch)
(char-upcase ch)
ch))
(a (char->integer #\A)))
(if (char<=? #\A ch #\Z)
(integer->char (+ (modulo (+ (- (char->integer ch) a) shift 26) 26) a))
ch))) text))
(define *text* "I LOVE YOU.")
(define *enc-text* (rotate *text* 3)) ; 暗号化
(define *dec-text* (rotate *enc-text* -3)) ; 復号化
(for-each (lambda (x)
(displayln (format "~a: ~a" (car x) (cadr x))))
`(("文字列" ,*text*) ("暗号化" ,*enc-text*) ("復号化", *dec-text*)))
I2xhbmcgcmFja2V0CgoocmVxdWlyZSAob25seS1pbiBzcmZpLzEzIHN0cmluZy1tYXApKQoKKGRlZmluZSAocm90YXRlIHRleHQgc2hpZnQpCiAgKHN0cmluZy1tYXAgKGxhbWJkYSAoY2gpCiAgICAgICAgICAgICAgICAobGV0ICgoY2ggKGlmIChjaGFyLWxvd2VyLWNhc2U/IGNoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoY2hhci11cGNhc2UgY2gpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoKSkKICAgICAgICAgICAgICAgICAgICAgIChhIChjaGFyLT5pbnRlZ2VyICNcQSkpKQogICAgICAgICAgICAgICAgICAoaWYgKGNoYXI8PT8gI1xBIGNoICNcWikKICAgICAgICAgICAgICAgICAgICAgIChpbnRlZ2VyLT5jaGFyICgrIChtb2R1bG8gKCsgKC0gKGNoYXItPmludGVnZXIgY2gpIGEpIHNoaWZ0IDI2KSAyNikgYSkpCiAgICAgICAgICAgICAgICAgICAgICBjaCkpKSB0ZXh0KSkKICAgICAgICAgICAgICAgICAgIAooZGVmaW5lICp0ZXh0KiAiSSBMT1ZFIFlPVS4iKQooZGVmaW5lICplbmMtdGV4dCogKHJvdGF0ZSAqdGV4dCogMykpIDsg5pqX5Y+35YyWCihkZWZpbmUgKmRlYy10ZXh0KiAocm90YXRlICplbmMtdGV4dCogLTMpKSA7IOW+qeWPt+WMlgooZm9yLWVhY2ggKGxhbWJkYSAoeCkKICAgICAgICAgICAgKGRpc3BsYXlsbiAoZm9ybWF0ICJ+YTogfmEiIChjYXIgeCkgKGNhZHIgeCkpKSkKICAgICAgICAgIGAoKCLmloflrZfliJciICwqdGV4dCopICgi5pqX5Y+35YyWIiAsKmVuYy10ZXh0KikgKCLlvqnlj7fljJYiLCAqZGVjLXRleHQqKSkp