您的位置:首页 > 服装鞋帽 > 男装 > 密码术入门(上)

密码术入门(上)

luyued 发布于 2011-06-06 11:27   浏览 N 次  

  密码术Cryprography,从希腊词Kryptos派生而来。它是一种为了使信息无法

  被外人理解,而对信息进行加密的技术。密码术通常分为两种,那就是易位和替

  换。

  栅栏密码:对于易位,不得不说栅栏密码,请先看下面的密文:

  TEOGSDYUTAENNHLNETAMSHVAED

  再看看解密过程:

  先将密文分为两行

  T E O G S D Y U T A E N N

  H L N E T A M S H V A E D

  再按上下上下的顺序组合成一句话

  THE LONGEST DAY MUST HAVE AN END.

  其实,还有多线的栅栏密码,大家试试解下面的密文:

  ASLELNASLAJLLHLWLDCHLVILABEAJKAHEL

  恺撒移位密码:然而,替换比易位更常用,古老的方法是随机的将字母两两配对,如:

  Q W E R T Y U I O P A S D

  !!!!!!!!!!!!!

  F G H J K L Z X C V B N M

  那么,句子Walls have ears.就被加密为Gbyyn ebph hbjn.

  后来,出现了恺撒移位密码,它是将字母表中的字母依次后移一定的位置得到的

  ,如:

  明码表 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  密码表 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E

  (密码学中用来书写原始信息的有关文字称为明码表,用来替换明码字母的有关

  字母称为密码表)

  明文 F O R E S T

  密文 K T W J X Y

  但恺撒密码的密钥只有可怜的25种,人们只需检查这25种可能性即可破解。大家

  又试试解下面的密文:

  1.QEBUB FP KL OLPB TFQELRQ D QELOK.

  2.WSKQUGEWWSKQYG

  单字母替换密码:因此,为了使密码有更高的安全性,单字母替换密码就出现了。

  只需重排密码表二十六个字母的顺序,密钥就会增加到四千亿亿亿多种,

  那么就能有效的防止敌人用筛选的方法检验所有的密钥,如:

  明码表 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  密码表 Q W E R T Y U I O P A S D F G H J K L Z X C V B N M

  明文 F O R E S T

  密文 Y G K T L Z

  这种密码持续使用几个世纪,直到阿拉伯人发明了密码破解术......

  本文的部分资料来自《密码故事》这本书(包括密码的历史,有关术语及一些数

  据,例题和练习由本人和黑尘翼落提供),建议大家买原书看看,里面的密码故

  事十分精彩哦~~~

  如果大家对这篇文章有什么疑问,见解或建议,请跟帖。本人还有一个恺撒移位

  密码破解不能,望黑尘翼落,hoon,drhorse等密码高手不吝指教,在此先谢过~

  ~~

  MHILY LZA ZBHL XBPZXBL MVYABUHL HWWPBZ JSHBKPBZ JHLJBZ KPJABT HYJHUBT

  LZA ULBAYVU

  to be continued......

  先给出上篇的答案:

  A S L E L N A S L A J L

  L H L W L D C H L V I

  L A B E A J K A H E L

  All shall be well and Jack shall have Jill.---有情人终成眷属。

  解答者:drhorse

  QEBUB FP KL OLPB TFQELRQ D QELOK.

  There is no rose without a thorn.---没有不带刺的玫瑰。

  解答者:drhorse

  (突破点有D,FP等,一般来说,英文文章单字母单词出现频率最多的是A,I;双

  字母单词出现较多的是IN,OF,IS,ON等;三字母的最多是THE,AND;四字母的

  有THAT等)

  WSKQUGEWWSKQYG

  Easy come,easy go.---来得容易去得快。

  解答者:drhorse

  (突破点是WSKQ,密文中出现了两次,不妨把它当作一个单词)

  MHILY LZA ZBHL XBPZXBL MVYABUHL HWWPBZ JSHBKPBZ JHLJBZ KPJABT HYJHUBT

  LZA ULBAYVU

  FABER EST SUAE QUISQUE FORTUNAE APPIUS CLAUDIUS CAECUS DICTUM ARCANUM

  EST NEUTRON

  解答者:drhorse

  (这是拉丁文,我看不懂,感谢drhorse将其破译,这是《密码故事》里的第2关)

  阿拉伯人的破译方法是"频率分析法",下面先说说各字母在英语文章中出现的频率

  (百分比)

  A:8.2 N:6.7

  B:1.5 O:7.5

  C:2.8 P:1.9

  D:4.3 Q:0.1

  E:12.7 R:6.0

  F:2.2 S:6.3

  G:2.0 T:9.1

  H:6.1 U:2.8

  I:7.0 V:1.0

  J:0.2 W:2.4

  K:0.8 X:0.2

  L:4.0 Y:2.0

  M:2.4 Z:0.1

  当然,这只是个概数,不会与每篇文章的字母出现频率完全一样,通常越短的信

  息的字母频率与上面的相比就越不相符,越短的信息也就越难破解了。如:

  John,a jazzist,will go to Japan in June to join a jazz party.

  其中,J的百分比是12.8,而E的百分比是0,对其进行频率分析就毫无意义。

  又如:UOCT XH.若

  明码表 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  密码表 Q W E R T Y U I O P A S D F G H J K L Z X C V B N M

  则它被翻译为GIVE UP.

  但若

  明码表 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  密码表 Q W U E T R Y I X P A S C H O M D F G J K L Z V B N

  则它被翻译为COME IN.

  究竟那个是真的,不得而知。但当它放进一篇文章里,就可从前后推知它应怎样

  翻译了。

  再来看看下面的密文:

  ......YSZX E NATRXZR GZEXM EDY LT 1640 CNZ NZER YB CNZ KEMOZXSLUUZ

  BEHLUG FEM MLX NADY KEMOZXSLUUZ NZ FEM E FLUR ETR ZSLU HET NZ FEM PXAZU

  ETR ZTVYGZR NATCLTD WZYWUZ MLX NADY BZUU LT UYSZ FLCN CNZ READNCZX YB

  E BEXHZX FNY FEM E TZLDNKYAX YB NLM CNZ GYATD FYHET FEM EBXELR YB CNZ

  ZSLU NADY ETR ESYLRZR NLH YTZ REG NADY NZEXR CNEC NZX BECNZX ETR

  KXYCNZXM FZXZ EFEG NZ OTZF CNEC MNZ FYAUR KZ EUYTZ MY NZ XYRZ CY CNZ

  BEXH FLCN BLSZ YX MLI YB NLM ZSLU BXLZTRM CNZG HERZ CNZ DLXU DY KEPO CY

  KEMOZXSLUUZ NEUU FLCN CNZH ETR UYPOZR NZX LT E XYYH AWMCELXM CNZT CNZG

  MEC RYFT LT CNZ DXZEC RLTLTD NEUU CY RXLTO EM AMAEU CNZG RXETO KYCCUZ

  EBCZX KYCCUZ ETR MYYT CNZG KZDET CY MLTD ETR UEADN ETR MNYAC ZSLU

  FYXRM......(约550个字母)

  先对它进行频率分析(出现次数/百分比)

  A:16/2.9 N:46/8.4

  B:14/2.5 O: 8/1.5

  C:38/6.9 P: 3/0.5

  D:16/2.9 Q: 0/0.0

  E:54/9.8 R:29/5.3

  F:17/3.1 S:11/2.0

  G:10/1.8 T:35/6.4

  H: 9/1.6 U:29/5.3

  I: 1/0.2 V: 1/0.2

  J: 0/0.0 W: 3/0.5

  K:10/1.8 X:34/6.2

  L:34/6.2 Y:41/7.5

  M:27/4.9 Z:65/11.8

  可发现E,Z出现的频率很高,那么我们可假设Z=E,E=A或Z=A,E=E。看看原

  来的文章,其中E以单字母单词出现,那么基本上Z=E,E=A。

  (还有些辨别E和A的方法,如一般文章中EE出现的频率比AA高)

  再来看看,CNZ,ETR作为三字母单词出现多次,那么他们有可能分别是THE和AND

  那么C=T,N=H,T=N,R=D。再说,文章中C,N,T,R出现的频率分别是:

  6.9,8.4,6.4,5.3,除了C有一点偏差以外,其余的和标准频率都差不多,不妨

  继续下去。

  又看看,文章中出现过LT 1640。若T=N的话,L就应该是I了,原文中LT CNZ就是

  IN THE了,上面的推理应该无误。

  又看文中,出现了CNZ NZER YB CNZ KEMOZXSLUUZ,YB也出现过几次,而我们知道

  CNZ=THE,那么这是不是THE XXXX OF THE XXXXXXXXXXX呢,YB=OF?Y,B出现的

  频率是7.5,2.5,标准频率中O,F出现的频率是7.5,2.2,好像是吧?而后面出

  现过几个CY,就是TO了,英文中TO出现的频率也颇高,就又证实了自己的推理。

  当我们解密的时候,除了大胆假设,还要不时运用其他证据来证实自己的推理,

  否则很容易到了最后才发现自己的错误,那又要花大量时间重头做起了。

  现在找找和Y有关的单词,可发现文中有一个MY,有可能是NO和SO,假设是NO,那

  与后面的NZ(HE)就组成NO HE,好像不大通顺,如果是SO HE就比较通顺了,M应

  该就是S了。接着,由NLH和HET推出H=M,又推出FYHET和FNY中F=W,从1640知道

  文章使用过去时态,那么FEM代表WAS应是正确的。

  现在概括一下:

  明码表 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  密码表 E R Z B N L H T Y M C F

  to be continued......

  将其代入原文,得:

  ......oSeX a hAndXed GeaXs aDo in 1640 the head of the KasOeXSiUUe

  famiUG was siX hADo KasOeXSiUUe he was a wiUd and eSiU man he was PXAeU

  and enVoGed hAntinD WeoWUe siX hADo feUU in UoSe with the daADhteX of

  a faXmeX who was a neiDhKoAX of his the GoAnD woman was afXaid of the

  eSiU hADo and aSoided him one daG hADo heaXd that heX fatheX and

  KXotheXs weXe awaG he Onew that she woAUd Ke aUone so he Xode to the

  faXm with fiSe oX siI of his eSiU fXiends theG made the DiXU Do KaPO to

  KasOeXSiUUe haUU with them and UoPOed heX in a Xoom AWstaiXs then theG

  sat down in the DXeat dininD haUU to dXinO as AsAaU theG dXanO KottUe

  afteX KottUe and soon theG KeDan to sinD and UaADh and shoAt eSiU

  woXds......(小写的是替换后的,大家可不看后面自己推推)

  那就好看多了,文中有句......that heX BatheX and KXotheXs weXe......,

  可推出X=R,又由oSeX a hAndXed GeaXs aDo等提示可推出A=U,S=V,G=Y,

  D=G。注意到文中有单词haUU,查字典易知符合条件的只有HALL,所以U=L。

  又有fiSe oX siI,即five or siI,那么I=X。由......the DiXU Do KaPO to

  ......推出K=B。由......he Onew that......推出O=K。由.....enVoGed

  hAntinD WeoWUe......推出V=J,W=P。由......he was PXAeU.....和结合上下

  文可知P=C。那么就有:

  明码表 A B C D E F G H I J K L M N O P R S T U V W X Y

  密码表 E K P R Z B D N L V O U H T Y W X M C A S F I G

  最后整篇文章就出来了:

  ......Over a hundred years ago,in 1640,the head of the Baskerville

  family was Sir Hugo Baskerville.He was a wild and evil man he was cruel

  and enjoyed hunting people.Sir Hugo fell in love with the daughter of a

  farmer who was a neighbour of his.The young woman was afraid of the

  evil Hugo,and avoided him.One day,Hugo heard that her father and

  brothers were away.He knew that she would be alone.So he rode to the

  farm with five or six of his evil friends.They made the girl go back to

  Baskerville Hall with them and locked her in a room upstairs.Then they

  sat down in the great dining hall to drink.As usual they drank bottle

  after bottle and soon they began to sing and laugh and shout evil

  words......

  总结一下吧,解单字母替换密码,首先要进行频率分析,确认几个频率较高和较

  低的几个字母,再根据英文本身的特点进行分析,并寻找一定的证据证明自己的

  结论,假设的同时要和标准频率对照一下,特别要注意上下文的连贯性,那就可

  以了。大家不妨拿黑尘翼落的密文2做一下,稍难但出得不错哦。至于我的练习

  明天才放出吧~~~

  to be continue......

  现放出上篇的练习:

  1.MQPUOZ WOLN DNLWZOUVNG MWFNPND EMQE EMN YXATWSY YEWWG HWD SNEENDY QOG

  MQPUOZ QIISUNG EMN DCSNY FMULM ZCUGN CY UO QSS HWDAY WH YNLDNE FDUEUOZY

  EMN YWSCEUWO FQY NQYX NOWCZM EMN HUDYE ANYYQZN YCTAUEENG EW AN FQY YW

  YMWDE EMQE UE FQY UAIWYYUTSN HWD AN EW GW AWDN EMQO EW YQX FUEM YWAN

  LWOHUGNOLN EMQE EMN YXATWS WH EMN YEULBAQO FUEM TWEM QDAY NKENOGNG CI

  UO EMN QUD YEWWG HWD N QY XWC QDN QFQDN N UY EMN AWYE LWAAWO SNEEND UO

  EMN NOZSUYM QSIMQTNE QOG UE IDNGWAUOQENY EW YW AQDBNG QO NKENOE EMQE

  NPNO UO Q YMWDE YNOENOLN WON FWCSG NKINLE EW HUOG UE AWYE WHENO WCE WH

  HUHENNO YXATWSY UO EMN HUDYE ANYYQZN HWCD FNDN EMN YQAN YW UE FQY

  DNQYWOQTSN EW YNE EMUY GWFO QY N UE UY EDCN EMQE UO YWAN LQYNY EMN

  HUZCDN FQY TNQDUOZ Q HSQZ QOG UO YWAN LQYNY OWE TCE UE FQY IDWTQTSN

  HDWA EMN FQX UO FMULM EMN HSQZY FNDN GUYEDUTCENG EMQE EMNX FNDN CYNG EW

  TDNQB EMN YNOENOLN CI UOEW FWDGY U QLLNIENG EMUY QY Q MXIWEMNYUY QOG

  OWENG EMQE N FQY DNIDNYNOENG TX EMN YEULBAQO FUEM TWEM QDAY NKENOGNG CI

  UO EMN QUD

  2.U B H X P P R A I L A F X K A E L U F L U L D G A A N V C D U M A K R

  D U K L X C M A R H X P E U C C B U M K I L D I U I R U M V C H M A D M

  R F X M A L A O A D I X M F A U E D R F X M G U M F A K I L D I U I E D

  R D M U M G U I D I U X M E L U F L L A E X P C K M X I O A B P R A R U

  M F A L A F X P C K M A G A O U M D Y U M A I L D I U I F X P C K F X M

  A B O X M D M H X M A W P I I L A C D K H D M K R X M H K A D O E D I R

  X M E A L D G A A M K A K W H I P O M U M Y I L A K D M F U M Y M A M I

  X Y X X K E L A M I L A H L D G A R X X B I A M W A A M I L A D Y A M I

  R X B A G U C D M K U I L U M S I L D I U L D G A B P C B U C C A K M H

  V O X M U R A X B Y U G U M Y H X P R X M A I L U M Y P M P R P D C B X

  O H X P O M X I A W X X S I L O A A B X O I H U R X P O I O D U M D M K

  U B D M F H E A R L X P C K W A W D F S U M W D S A O R I O A A I B X O

  K U M M A O

  (提示:留意重复出现的连续多个字母,如I L D I。这种方法在解维尔纳斯密码

  时很有用哦~~~)

  下面再说说一些常用技巧:

  1.辨认出E后,能轻易的标出H,因为H常常出现在E前,却很少位于其后;

  2.Q的后面多是U;

  3.当一个单词知道其中大部分字母后,不妨查查英文字典(当然,很懂E文的就不

  用了~~~),如果字典里只有一个单词符合条件时,就会很快的知道其他字母。

  上面的只是抛砖引玉,希望大家有什么好方法也告诉一下~~~

  解密或许是个沉闷的过程,但当你找到解法后,又会很兴奋,大家ENJOY一下吧!

  先给出上篇的答案吧:

  1."Having once recognized, however, that the symbols stood for letters,

  and having applied the rules which guide us in all forms of secret

  writings, the solution was easy enough. The first message submitted to

  me was so short that it was impossible for me to do more than to say,

  with some confidence, that the symbol [of the stickman with both arms

  extended up in the air] stood for E. As you are aware, E is the most

  common letter in the English alphabet, and it predominates to so marked

  an extent that even in a short sentence one would expect to find it

  most often. Out of fifteen symbols in the first message, four were the

  same, so it was reasonable to set this down as E. It is true that in

  some cases the figure was bearing a flag, and in some cases not but it

  was probable, from the way in which the flags were distributed, that

  they were used to break the sentence up into words. I accepted this as

  a hypothesis, and noted that E was represented by [the stickman with

  both arms extended up in the air]

  明码表 A B C D E F G H I J K L M N O P R S T U V W X Y

  密码表 Q T U G N H Z M U R B S A O W I D Y E C P F K X

  解答者:drhorse,菩提

  (这篇的难点是E以特殊的形式出现,令单字母单词有三个)

  2."If you use the code which I have explained," said Holmes, "you will

  find that it simply means 'Come here at once.' I was convinced that it

  was an invitation which he would not refuse, since he could never

  imagine that it could come from anyone but the lady. And so, my dear

  Watson, we have ended by turning the dancing men to good when they

  have so often been the agents of evil, and I think that I have

  fulfilled my promise of giving you something unusual for your

  notebook. Three-forty is our train, and I fancy we should be back in

  Baker Street for dinner."

  明码表 A B C D E F G H I K L M N O P R S T U V W X Y

  密码表 D W F K A B Y L U S C M M X V O R I P G E N H

  解答者:hoon

  (这篇的难点是M既替换N,又是本身,这是后来一些编码师用来迷惑破译者而设

  的陷阱)

  自从频率分析法出现后,单字母替换密码完全失去了效用。因此,密码编码者想

  方设法去编一种更强大的密码。一些编码者对单字母替换密码做了一些改动,如

  在编码过程中,加入一些特殊的字符,或者令一些字母不代表另一个字母,而是

  代表一种程式,譬如是代表空格,代表删去前一个字母,代表换行等。但这一切

  起的作用并不大,聪明的破译师仍然能在里面找到许许多多破译密码的线索。直

  到有一天,佛罗伦萨的里昂巴蒂斯特

广告赞助商