原文发在BBS上,转载过来,《密码编码学与网络安全:原理与实践》上的一道题,课本中提示为隐写术

In one of Dorothy Sayers's mysteries, Lord Peter is confronted with the messag
e shown below. He also discovers the key to the message, which is a sequence o
f integers:


7876565434321123434565678788787656543432112343456567878878765654433211234

message:

I thought to see the fairies in the fields, but I saw only the evil elephants
with their black backs. Woe! how that sight awed me! The elves danced all arou
nd and about while I heard voices calling clearly.Ah! how I tried to see-throw
off the ugly cloud-but no blind eye of a mortal was permitted to spy them. So
then came minstrels, having gold trumpets, harps and drums. These played very
loudly beside me, breaking that spell. So the dream vanished, whereat I thank
ed Heaven. I shed many tears before the thin moon rose up, frail and faint as
a sickle of straw. Now though the Enchanter gnash his teeth vainly, yet shall
he return as the spring returns. Oh, wretched man! Hell gapes, Erebus now lies
open. The mouths of Death wait on thy end.

(a) Decrypt the message. [Hint: What is the largest integer value?]
(b) If the algorithm is known but not the key, how secure is the scheme?
(c) If the key is known but not the algorithm, how secure is the scheme?

至少在Google和Baidu上没找到答案
就做第一问了

写了一个小程序

#include <iostream>
#include <string>
#include <fstream>


using namespace std;

int main()
{
   ifstream in("cipher.txt");
   string key;
   string line;
 
   getline(in, key);
 
   int count = 0;
 
   
   while (getline(in, line))
   {
      cout << line.at(key.at(count++) - '1');
   }
 
    in.close();
 
    return 0;
}

同时把密文中所有的空格,标点和换行全部删去,用EmEditor的宏功能将字符串拆分成8个字一行(这个真是个好东东吖,尤其是它的宏录制功能,用它,比用什么perl写个脚本处理字符串爽吖,只管按F4键就好),生成一个文件cipher.txt
7876565434321123434565678788787656543432112343456567878878765654433211234
Ithought
toseethe
fairiesi
nthefiel
dsbutIsa
wonlythe
evilelep
hantswit
htheirbl
ackbacks
Woehowth
atsighta
wedmeThe
elvesdan
cedallar
oundanda
boutwhil
eIheardv
oicescal
lingclea
rlyAhhow
Itriedto
seethrow
offtheug
lycloudb
utnoblin
deyeofam
ortalwas
permitte
dtospyth
emSothen
camemins
trelshav
inggoldt
rumpetsh
arpsandd
rumsThes
eplayedv
eryloudl
ybesidem
ebreakin
gthatspe
llSothed
reamvani
shedwher
eatIthan
kedHeave
nIshedma
nytearsb
eforethe
thinmoon
roseupfr
ailandfa
intasasi
ckleofst
rawNowth
oughtheE
nchanter
gnashhis
teethvai
nlyyetsh
allheret
urnasthe
springre
turnsOhw
retchedm
anHellga
pesErebu
snowlies
openThem
outhsofD
eathwait
onthyend

然后运行程序,得到如下字符
hesittethbetweenthecherubimstheislesmaybegladtHereofastheriversintHesouth

分割一下
he sitteth between the cherubims.the isles may be glad thereof as the rivers in the south.