? ? 以前講過凱撒密碼是一種移位加密,密鑰就是平移的字母的個(gè)數(shù)器联。由于字母表只有26個(gè)字母蕉世,因此加密用的密鑰只有0到25共26種(密鑰為0相當(dāng)于沒有加密),因此凱撒密碼可以通過暴力破解來破譯狭姨。暴力破解是指將所有可能的密鑰全部嘗試一遍宰啦,又稱為窮舉搜索。
? ? 而簡(jiǎn)單替換密碼很難通過暴力破解來破譯饼拍。這是因?yàn)楹?jiǎn)單替換密碼可以使用的密鑰數(shù)量比凱撒密碼要多得多赡模。簡(jiǎn)單替換密碼中,明文a可以對(duì)應(yīng)A~Z這26個(gè)字母的任意一個(gè)师抄,b可以對(duì)應(yīng)除a對(duì)應(yīng)的字母以外的剩余25個(gè)字母中的任意一個(gè)漓柑。以此類推,簡(jiǎn)單替換密碼的密鑰總數(shù)為:
26*25*24*23*…*1= 403291461126605635584000000
這么龐大的數(shù)字叨吮,如果用暴力破解辆布,即使每秒能夠遍歷10億個(gè)密鑰,要遍歷完也需要120億年茶鉴。
? ? 因?yàn)槠谱g困難谚殊,從公元前開始,簡(jiǎn)單替換密碼在幾百年的時(shí)間里一直被用于秘密通信蛤铜。然而在阿拉伯學(xué)者發(fā)明了頻率分析法之后嫩絮,這種密碼就可以被破譯了。頻率分析法利用了明文中字母的出現(xiàn)頻率與密文中字母出現(xiàn)的頻率一致這一特性围肥。有以下分析方法:
1剿干、英語中出現(xiàn)頻率最高的字母是e,假定密文中出現(xiàn)頻率最高的字母是e
2穆刻、 英語中出現(xiàn)最多的單詞是The
3置尔、 英語文章中9個(gè)最常用的字母是e,t氢伟,a榜轿,o幽歼,n,i谬盐,r甸私,s, h
4、英語單詞中有一半以上是以t飞傀,a皇型,o,s或w開頭的
5砸烦、 僅10個(gè)單詞(the弃鸦,of,and幢痘,to唬格,a,in颜说,that西轩,it,is和I)就構(gòu)成標(biāo)準(zhǔn)英語文章四分之一以上的篇幅
6脑沿、 密文越長(zhǎng)越容易破譯。
【案例分析】
? ? 我們以小說《金甲蟲》中藏寶圖上的密碼為例马僻,使用頻率分析法進(jìn)行破譯:
53§§+305))6*;4826)4§.)4§);806*;48+8β60))85;;]8*;:§*8+83(88)5*+;46(;88*96*?;8)*§(;485);5*+2:*§(;4956*2(5*-4)8β8*;4069285);)6+8)4§§;;1(§9;48081;8:8§1;48+85;4)485+528806*81(§9;48;(88;4(§?34;48)4§;161;:188;§?;
? ? 首先庄拇,我們統(tǒng)計(jì)一下這段密文中每個(gè)符號(hào)出現(xiàn)的頻率,排出前幾位的符號(hào):
? ? 一般英語文章中出現(xiàn)頻率最高的字母是e韭邓,該段密文中出現(xiàn)頻率最高的符號(hào)是8措近,我們假設(shè)8->e,將密文中的8全部替換女淑,替換后的密文如下:
53§§+305))6*;4e26)4§.)4§);e06*;4e+eβ60))e5;;]e*;:§*e+e3(ee)5*+;46(;ee*96*?;e)*§(;4e5);5*+2:*§(;4956*2(5*-4)eβe*;40692e5);)6+e)4§§;1(§9;4e0e1;e:e§1;4e+e5;4)4e5+52ee06*e1(§9;4e;(ee;4(§?34;4e)4§;161;:1ee;§?;
? ? 英語中出現(xiàn)最多的單詞是the瞭郑,我們尋找一下以e結(jié)尾的3個(gè)字符組合,發(fā)現(xiàn);4e這3個(gè)字符的組合是最常出現(xiàn)的鸭你,很有可能就是the屈张。于是我們假設(shè);->t,4->h袱巨,而且;->t也符合t出現(xiàn)頻率較高的規(guī)則:
53§§+305))6*the26)h§.)h§)te06*the+eβ60))e5tt]e*t:§*e+e3(ee)5*+th6(tee*96*?te)*§(the5)t5*+2:*§(th956*2(5*-h)eβe*th0692e5)t)6+e)h§§t1(§9the0e1te:e§1the+e5th)he5+52ee06*e1(§9thet(eeth(§?3hthe)h§t161t:1eet§?t
? ? 我們發(fā)現(xiàn)中間有一些詞比較可疑:thet(ee可能是the tree吧阁谆,嘗試(->r:
53§§+305))6*the26)h§.)h§)te06*the+eβ60))e5tt]e*t:§*e+e3ree)5*+th6rtee*96*?te)*§rthe5)t5*+2:*§rth956*2r5*-h)eβe*th0692e5)t)6+e)h§§t1r§9the0e1te:e§1the+e5th)he5+52ee06*e1r§9thetreethr§?3hthe)h§t161t:1eet§?t
? ? th6rtee*很難不聯(lián)想到thirteen,假設(shè)6->i愉老,*->n:
53§§+305))inthe2i)h§.)h§)te0inthe+eβi0))e5tt]ent:§ne+e3ree)5n+thirteen9in?te)n§rthe5)t5n+2:n§rth95in2r5n-h)eβenth0i92e5)t)i+e)h§§t1r§9the0e1te:e§1the+e5th)he5+52ee0ine1r§9thetreethr§?3hthe)h§t1i1t:1eet§?t
? ? thetreethr§?3hthe這個(gè)組合场绿,可能是the tree through the,§->o嫉入,?->u焰盗,3->g:
5goo+g05))inthe2i)ho.)ho)te0inthe+eβi0))e5tt]ent:one+egree)5n+thirteen9inute)northe5)t5n+2:north95in2r5n-h)eβenth0i92e5)t)i+e)hoot1ro9the0e1te:eo1the+e5th)he5+52ee0ine1ro9thetreethroughthe)hot1i1t:1eetout
? ? 為了方便查看璧尸,對(duì)已識(shí)別的單詞加入空格:
5goo+g05)) in the 2i)ho.)ho)te0 in the +eβi0))e5tt]ent:one+egree)5n+ thirteen 9inute)northe5)t5n+2:north95in2r5n-h)eβenth0i92e5)t)i+e)hoot1ro9the0e1te:eo1the+e5th)he5+52ee0ine1ro9the tree through the )hot1i1t:1eet out
? ? 9inute)可能是minutes,thirteen minutes也說得通熬拒,9->m爷光,)->s
5goo+g05ssin the 2isho.shoste0 in the +eβi0sse5tt]ent:one+egrees5n+thirteen minutes northe5st5n+2:northm5in2r5n-hseβenth0im2e5stsi+eshoot1romthe0e1te:eo1the+e5thshe5+52ee0ine1romthe tree through the shot1i1t:1eet out
? ? 發(fā)現(xiàn)有一組是northe5st5nd,northe5st可能是northeast梦湘;5n+多次出現(xiàn)瞎颗,可能是一個(gè)單詞;而且高頻字母中的a還沒有找到對(duì)應(yīng)的字符捌议,5也在高頻符號(hào)中哼拔,假設(shè)5->a,+->d:
A good g0assin the 2isho.shoste0 in the deβi0sseatt]ent:one degrees and thirteen minutes northeast and 2:northmain2ran-hseβenth0im2east side shoot 1rom the 0e1te:eo1 the deathsheada2ee0ine1romthe tree through the shot 1i1t:1eet out
? ? g0ass可能是grass,glass瓣颅,由于前面假設(shè)(->r倦逐,所以這里0-l:
a good glass in the 2isho.shostel in the deβilsseatt]ent:one degrees and thirteen minutes northeast and 2: north main 2ran-hseβenthlim2east side shoot 1rom the le1te:eo1 the deaths head a2eeline1romthe tree through the shot1i1t:1eet out
? ? 1rom可能是from,1-f:
A good glassin the 2isho.s hostel in the deβilsseatt]ent: one degreesand thirteen minutes? northeast and 2: northmain 2ran-hseβenthlim2east side shoot from the left e:eofthe deathsheada2eeline from the tree through the shot fift:feet out
? ? fift:feet可能是fiftyfeet宫补,:->y:
A good glassin the 2isho.s hostel in the deβilsseatt]enty one degreesand thirteen minutes northeast and 2y north main 2ran-hseβenthlim2eastside shoot from the left eye of the deathsheada2eeline from the tree through theshot fifty feet out
? ? 2y應(yīng)該是by檬姥,2->b:
A good glassin the bisho.s hostel in the deβilsseatt]enty one degreesand thirteen minutes northeast and by north main bran-hseβenthlimb east side shoot from the left eye of the death's head a beeline from the treethrough the shot fifty feet out
? ? bisho.s應(yīng)該是bishops;bran-h應(yīng)該是branch粉怕,seβenth應(yīng)該是seventh健民,所以.->p,- ->c贫贝,β->v:
A good glassin the bishop's hostel in the devil's seat t]enty one degrees and thirteen minutesnortheast and by north main branch seventh limb east side shoot from the left eyeof the death's head a beeline from the tree through the shot fifty feet out
? ? 最后]對(duì)應(yīng)到w:
A good glassin the bishop's hostel in the devil's seat twenty-one degrees and thirteen minutesnortheast and by north main branch seventh limb east side shoot from the left eyeof the death's head a beeline from the tree through the shot fifty feet out.
? ? 中文翻譯如下:
一面好鏡子在皮肖甫客店魔椅──二十一度十三分──東北偏北──最大樹枝第七根椏枝東面──從骷髏頭左眼射擊──從樹前引一直線距線通過子彈延伸五十英尺秉犹。