頻率分析法

? ? 以前講過凱撒密碼是一種移位加密,密鑰就是平移的字母的個數(shù)。由于字母表只有26個字母,因此加密用的密鑰只有0到25共26種(密鑰為0相當(dāng)于沒有加密),因此凱撒密碼可以通過暴力破解來破譯。暴力破解是指將所有可能的密鑰全部嘗試一遍,又稱為窮舉搜索。

? ? 而簡單替換密碼很難通過暴力破解來破譯。這是因為簡單替換密碼可以使用的密鑰數(shù)量比凱撒密碼要多得多。簡單替換密碼中,明文a可以對應(yīng)A~Z這26個字母的任意一個,b可以對應(yīng)除a對應(yīng)的字母以外的剩余25個字母中的任意一個。以此類推,簡單替換密碼的密鑰總數(shù)為:

26*25*24*23*…*1= 403291461126605635584000000

這么龐大的數(shù)字,如果用暴力破解,即使每秒能夠遍歷10億個密鑰,要遍歷完也需要120億年。

? ? 因為破譯困難,從公元前開始,簡單替換密碼在幾百年的時間里一直被用于秘密通信。然而在阿拉伯學(xué)者發(fā)明了頻率分析法之后,這種密碼就可以被破譯了。頻率分析法利用了明文中字母的出現(xiàn)頻率與密文中字母出現(xiàn)的頻率一致這一特性。有以下分析方法:

1、英語中出現(xiàn)頻率最高的字母是e,假定密文中出現(xiàn)頻率最高的字母是e

2、 英語中出現(xiàn)最多的單詞是The

3、 英語文章中9個最常用的字母是e,t,a,o,n,i,r,s, h

4、英語單詞中有一半以上是以t,a,o,s或w開頭的

5、 僅10個單詞(the,of,and,to,a,in,that,it,is和I)就構(gòu)成標(biāo)準英語文章四分之一以上的篇幅

6、 密文越長越容易破譯。

【案例分析】

? ? 我們以小說《金甲蟲》中藏寶圖上的密碼為例,使用頻率分析法進行破譯:

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)計一下這段密文中每個符號出現(xiàn)的頻率,排出前幾位的符號:

? ? 一般英語文章中出現(xiàn)頻率最高的字母是e,該段密文中出現(xiàn)頻率最高的符號是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個字符組合,發(fā)現(xiàn);4e這3個字符的組合是最常出現(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這個組合,可能是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

? ? 為了方便查看,對已識別的單詞加入空格:

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),可能是一個單詞;而且高頻字母中的a還沒有找到對應(yīng)的字符,5也在高頻符號中,假設(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

? ? 最后]對應(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.

? ? 中文翻譯如下:

一面好鏡子在皮肖甫客店魔椅──二十一度十三分──東北偏北──最大樹枝第七根椏枝東面──從骷髏頭左眼射擊──從樹前引一直線距線通過子彈延伸五十英尺。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容