暗号解読の作問をするためのプログラムを Smalltalk(Squeak 6.0) で書いてみました。ソースコードは以下の通りです。
|plainText cryptoKey stream|
plainText := 'This is plain text.' asLowercase.
cryptoKey := Character alphabet shuffle.
Transcript cr; show: 'Key is: ' , cryptoKey; cr.
stream := TextStream with: ''.
plainText do: [:each ||index|
index := Character alphabet indexOf: each.
index = 0 ifTrue: [
stream nextPut: each.
]
ifFalse: [
stream nextPut: (cryptoKey at: index).
]
].
Transcript cr; show: stream contents.
結果、こんな問題が出来ました。
https://gist.github.com/satoyuichi/f27b3b9b9911da69c7dce5977f27c2d1
解説
暗号は単アルファベット換字式暗号です。アルファベットをスクランブルしたものを鍵として、平文を暗号化しています。平文をすべて小文字に変換しているのは解読しやすくするためです。記号やスペースをそのままにしているのも解読しやすくするためですが、同様にスクランブルするのであれば、
cryptoKey := Character alphabet shuffle.
を
cryptoKey := (Character alphabet , '.,:; ') shuffle.
などのようにすれば対応できます。