加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

密码学中几个小故事的破解

(2009-09-19 22:44:29)
标签:

密码学

破解

playfair

pt-109

海军上尉

隐写术

greetings

to

all

at

oxford

it

1.美国海军上尉截获日本毁灭者准备击沉PT-109的用playfair加密的密文:

KXJEY  UREBE  ZWEHE WRYTU HEYFS
KREHE GOYFI  WTTTU OLKSY  CAJPO
BOTEI  ZONTX  BYBNT GONEY CUZWR
GDSON SXBOU YWRHE BAAHY USEDQ

密钥: royal new zealand navy ,

比较特殊的是,要将TT换为tt 。明文:pt boat one owe nine lost in action in blackett strait two miles swmeresucoce(不知怎样分解出单词) crew of twelve.request any information.

2.隐写术 (侦探Morse的困惑)

原文比较长,我只写个开头吧

Dear George,

Greetings to all at Oxford.Many thanks for your...

真实的寓意隐藏在每行的最后一个单词中,连接起来就是:your package ready friday 21st ,room three,please destroy this immediately.
3.隐写术 (地主彼得的迷惑)

将密文每8个一组(不包括标点和空格,8 是密钥中最大的整数),密钥的值就是明文在分组中的位置。

程序实现如下:

#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 char cipher[]="ithoughttoseethefairiesinthefieldsbutisawonlytheevilelephantswiththeirblackbackswoehowthatsightawedmetheelvesdancedallaroundandaboutwhileiheardvoicescallingclearlyahhowitriedtoseethrowofftheuglycloudbutnoblindeyeofamortalwaspermittedtospythemsothencameminstrelshavinggoldtrumpetsharpsanddrumstheseplayedveryloudlybesidemebreakingthatspellsothedreamvanishedwhereatithankedheavenishedmanytearsbeforethethinmoonroseupfrailandfaintasasickleofstrawnowthoughtheenchantergnashhisteethvainlyyetshallhereturnasthespringreturnsohwretchedmanhellgapeserebusnowliesopenthemouthsofdeathwaitonthyend";
 int length=sizeof(cipher);
   int code[]={7,8,7,6,5,6,5,4,3,4,3,2,1,1,2,3,4,3,4,5,6,5,6,7,8,7,8,8,7,8,7,6,5,6,5,4,3,4,3,2,1,1,2,3,4,3,4,5,6,5,6,7,8,7,8,8,7,8,7,6,5,6,5,4,4,3,3,2,1,1,2,3,4};
   for(int i=0;i<length/8;i++)
 {
  cout<<cipher[i*8+code[i]-1];
 }
 return 0;
}

最终明文: he sittech(古英语) between the chrubims the isles maybe glad thereof as the rivers in the south

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有