常见加密、解密、破解

目录

一,平移加密

二,字母表加密

三,生成序列平移法

四,多密码表加密

五,恩尼格玛密码机(Enigma)

1,转子

2,转子组

3,插线板

4,反射器

5,转子组重设操作

6,恩尼格玛密码机的破解

7,恩尼格玛密码机的升级配置


一,平移加密

假设文本只有a-z这26个小写英文字母,取一个数字k,把字母x变成(x+k)%26传递出去,这就完成了加密。

但是这种只有26种情况,可以一种种试出来。

这是一种对称加密,其中k就是秘钥。

加密机:

#include<iostream>
using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    for (int i = 0; i < s.length(); i++)cout << char((s[i] - 'a' + k) % 26 + 'a');
    return 0;
}

运行:

1
love
mpwf

有秘钥的解密机:

#include<iostream>
using namespace std;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    for (int i = 0; i < s.length(); i++)cout << char((s[i] - 'a' - k+26) % 26 + 'a');
    return 0;
}

运行:

1
mpwf
love

如果黑客知道是这个算法,或者猜到是这个算法,哪怕只是试一下,那么无非就26种情况。

无秘钥的破解方案:

#include<iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int k = 0; k < 26; k++) {
        for (int i = 0; i < s.length(); i++)cout << char((s[i] - 'a' - k + 26) % 26 + 'a');
        cout << endl;
    }
    return 0;
}

运行:

mpwf
mpwf
love
knud
jmtc
ilsb
hkra
gjqz
fipy
ehox
dgnw
cfmv
belu
adkt
zcjs
ybir
xahq
wzgp
vyfo
uxen
twdm
svcl
rubk
qtaj
pszi
oryh
nqxg

在输出的26个字符串中,可以轻易找到有意义的字符串love,这样就完成了破解。

二,字母表加密

假设还是26个英文字母,随机生成一个字母表对照表T,按照T进行字母替换的加密算法就是字母表加密。

其中T就是秘钥,这也是对称加密。

加密机:

#include<iostream>
using namespace std;

int main()
{
    string T = "qwertyuioplkjhgfdsazxcvbnm";
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)cout << T[s[i]-'a'];
    return 0;
}

运行:

iloveu
okgctx

有秘钥的解密机:

#include<iostream>
using namespace std;

int main()
{
    string T = "qwertyuioplkjhgfdsazxcvbnm";
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < 26; j++)if (T[j] == s[i])cout << char(j + 'a');
    }
    return 0;
}

运行:

okgctx
iloveu

无秘钥的破解方案:

靠暴力枚举肯定是不行的,主要破解方案是频率法。

为了测试,我们先写个语料处理器,把语料变成纯英文小写字母:

#include<iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z')cout << s[i];
        if (s[i] >= 'A' && s[i] <= 'Z')cout << char(s[i] - 'A' + 'a');
    }
    return 0;
}

于是我们得到一个纯英文小写字母的语料,在某个未知的字母表加密之后,它变成:

lermrtmrvvrcwlqacwxakrsercwgfvaqqqvrcwrqvfjeletlgfbfqlstcwllzajylervkmvgfmnmrtvqtcwnefhlervkmmrtxnmrtvsetlgfstcwllnmrtvh
sermrgfstcwllhdrsetlgfstcwlldrdrjtfqrgfetircwxgcwrxakrtcwncwrjetcwjrlntxxlerleacwhqgfstcwllnvtggfetirrcwfheetzzacwrqqlvt
yrgfqsrrlrcwfhelmatxqlvtyrgfqlmcwhrcwfheqmmslyrrzgfefvtcwrcwfheezrlvtyrgfetzzgtxstgqzflgfmqrxkacwlermqqerqakgfkrrxletlal
efmlqgfalzmdtdxgefmlqlerlermzrmqcwlleretzzarqlkzrzxrncwlcwrjrqqtmaxgetirlerdrqlkrirmgleacwhlergbfqlvtyrlervqlkrirmgleacw
hletljvrqtxcwhleramstgetzzacwrqqxarqkmleqrsejmgleqrseefmlleqrseetirqrtmjerntcwnleqrseetirlmarnkmcwxglergjtcwtzzmrjatlrle
ravzmltcwjrkzrzxrseetirlfjernleramxairqxirdrhacwqsaletqvaxrhmsqsaletyaqqtcwnrcwnqsaletlrtmlerdmahelrqlkflfmrsaxxtxstgqdr
dtqrncwtkmhllrcwztqlgfjtcwlhcwsrxxacwxakrfcwlaxgfxrlhkgfmztqlktaxfmrqtcwnertmltjerqsercwgfsrmrdmcwgfsrmrjmgacwhtcwnrirmg
cwrtmfcwngfstqqvaxacwhxairgfmxakrqletlsercwgfnargfmrlercwrseaqqvaxacwhtcwnrirmgcwrtmfcwngfaqjmgacwhzxrtqrqrcwnleaqvrqqth
rlleqrzrzxrsevrtcwqvrleacwhlgflleqrseetirlfjerngfmxakracwcwrstgmtcwlermlleqrsevtyrgfqvaxrsercwgfmrtxxgcwrrnallleqrletlvt
yrgfqrrlerdmahelrmqanrkleacwhqsercwgftmrmrtxxgnscwlleqrsegfstcwllxrllervycwsletlgftzzmrjatlrleramkmarcwnqeaztcwnakgfncwl
ncwlsmmgcwleacwhdtnsaxxetzzrcwlgfgfsaxxbfqlvaqqflcwlerzzmlfcwalgldmahelrcwqvrcwrqntgsaleleaqvrqqthr

我不知道字母表,我只能根据字母频率来破解。

字母统计程序:

#include<iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int num[26] = { 0 };
    for (int i = 0; i < s.length(); i++) {
        num[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++)cout << char('a' + i) << num[i] << endl;
    return 0;
}

这个没有排序,重新写个带排序的统计程序:

#include<iostream>
#include<algorithm>
using namespace std;

typedef struct {
    char c;
    int num;
}Node;

bool cmp(Node a, Node b)
{
    return a.num < b.num;
}

int main()
{
    string s;
    cin >> s;
    Node node[26];
    for (int i = 0; i < 26; i++)node[i].c = char('a' + i), node[i].num = 0;
    for (int i = 0; i < s.length(); i++) {
        node[s[i] - 'a'].num++;
    }
    sort(node, node + 26, cmp);
    for (int i = 0; i < 26; i++)cout << node[i].c << node[i].num << endl;
    return 0;
}

运行:

o0
p0
u0
b3
y10
d14
i14
j19
k23
h29
n32
v33
z33
s45
x46
g61
f62
m68
a69
q82
c83
w83
t92
e101
l127
r170

即rletwcqamfgxszvnhkjidybupo

对比Algoritmy网站给出的大语料统计频率数据:

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
8.17% 1.49% 2.78% 4.25% 12.70% 2.23% 2.02% 6.09% 6.97% 0.15% 0.77% 4.03% 2.41% 6.75% 7.51% 1.93% 0.10% 5.99% 6.33% 9.06% 2.76% 0.98% 2.36% 0.15% 1.97% 0.07%

按照字母频率排序就是:etaoinrshdclmpufgwybkjvxqz

根据2个频率表,得到初步判定的翻译程序:

#include<iostream>
using namespace std;

int main()
{
    string s = "lermrtmrvvrcwlqacwxakrsercwgfvaqqqvrcwrqvfjeletlgfbfqlstcwllzajylervkmvgfmnmrtvqtcwnefhlervkmmrtxnmrtvsetlgfstcwllnmrtvh\
        sermrgfstcwllhdrsetlgfstcwlldrdrjtfqrgfetircwxgcwrxakrtcwncwrjetcwjrlntxxlerleacwhqgfstcwllnvtggfetirrcwfheetzzacwrqqlvt\
        yrgfqsrrlrcwfhelmatxqlvtyrgfqlmcwhrcwfheqmmslyrrzgfefvtcwrcwfheezrlvtyrgfetzzgtxstgqzflgfmqrxkacwlermqqerqakgfkrrxletlal\
        efmlqgfalzmdtdxgefmlqlerlermzrmqcwlleretzzarqlkzrzxrncwlcwrjrqqtmaxgetirlerdrqlkrirmgleacwhlergbfqlvtyrlervqlkrirmgleacw\
        hletljvrqtxcwhleramstgetzzacwrqqxarqkmleqrsejmgleqrseefmlleqrseetirqrtmjerntcwnleqrseetirlmarnkmcwxglergjtcwtzzmrjatlrle\
        ravzmltcwjrkzrzxrseetirlfjernleramxairqxirdrhacwqsaletqvaxrhmsqsaletyaqqtcwnrcwnqsaletlrtmlerdmahelrqlkflfmrsaxxtxstgqdr\
        dtqrncwtkmhllrcwztqlgfjtcwlhcwsrxxacwxakrfcwlaxgfxrlhkgfmztqlktaxfmrqtcwnertmltjerqsercwgfsrmrdmcwgfsrmrjmgacwhtcwnrirmg\
        cwrtmfcwngfstqqvaxacwhxairgfmxakrqletlsercwgfnargfmrlercwrseaqqvaxacwhtcwnrirmgcwrtmfcwngfaqjmgacwhzxrtqrqrcwnleaqvrqqth\
        rlleqrzrzxrsevrtcwqvrleacwhlgflleqrseetirlfjerngfmxakracwcwrstgmtcwlermlleqrsevtyrgfqvaxrsercwgfmrtxxgcwrrnallleqrletlvt\
        yrgfqrrlerdmahelrmqanrkleacwhqsercwgftmrmrtxxgnscwlleqrsegfstcwllxrllervycwsletlgftzzmrjatlrleramkmarcwnqeaztcwnakgfncwl\
        ncwlsmmgcwleacwhdtnsaxxetzzrcwlgfgfsaxxbfqlvaqqflcwlerzzmlfcwalgldmahelrcwqvrcwrqntgsaleleaqvrqqthr";
    string T1 = "etaoinrshdclmpufgwybkjvxqz"; //大语料频率排序
    string T2 = "rletwcqamfgxszvnhkjidybupo"; //密文
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < 26; j++)if (T2[j] == s[i])cout << T1[j];
    }
    return 0;
}

翻译结果:

taeheoheuuenitrsnilswemaenicdusrrruenierudyataotcdvdrtmonittpsyjtaeuwhucdhfheouronifadgtaeuwhheolfheoumaotcdmonittfheoug
maehecdmonittgkemaotcdmonittkekeyodrecdaobenilcnielsweonifnieyaoniyetfolltaetasnigrcdmonittfuoccdaobeenidgaaoppsnierrtuo
jecdrmeetenidgathsolrtuojecdrthnigenidgarhhmtjeepcdaduonienidgaapetuojecdaoppcolmocrpdtcdhrelwsnitaehrraerswcdweeltaotst
adhtrcdstphkoklcadhtrtaetaehpehrnittaeaoppsertwpeplefnitnieyerrohslcaobetaekertwebehctasnigtaecvdrtuojetaeurtwebehctasni
gtaotyuerolnigtaeshmocaoppsnierrlserwhtaremayhctaremaadhttaremaaobereohyaefoniftaremaaobethsefwhnilctaecyonioppheysoteta
esuphtoniyewpeplemaaobetdyaeftaeshlsberlbekegsnirmstaorusleghmrmstaojsrronifenifrmstaoteohtaekhsgatertwdtdhemsllolmocrke
korefniowhgtteniportcdyonitgnimellsnilswednitslcdletgwcdhportwosldheronifaeohtoyaermaenicdmehekhnicdmeheyhcsnigonifebehc
nieohdnifcdmorruslsniglsbecdhlswertaotmaenicdfsecdhetaeniemasrruslsnigonifebehcnieohdnifcdsryhcsnigpleorereniftasruerrog
ettarepeplemaueoniruetasnigtcdttaremaaobetdyaefcdhlswesniniemochonitaehttaremauojecdruslemaenicdheollcnieefstttaretaotuo
jecdreetaekhsgatehrsfewtasnigrmaenicdoheheollcfmnittaremacdmonittlettaeujnimtaotcdoppheysotetaeshwhsenifrasponifswcdfnit
fnitmhhcnitasnigkofmsllaoppenitcdcdmsllvdrtusrrdtnitaepphtdnistctkhsgateniruenierfocmstatasruerroge

接下来就靠猜测加调整了,我们猜测taehe其实是there,那我们就需要把字母表换成T2=rltwcqmaefgxszvnhkjidybupo,

重新翻译:

there are uueiotnsiolswemheiocdusnnnueioenudyh that cdvdntmaiottpsyjtheuwrucdrfreaunaiofhdgtheuwrrealfreaumhatcdmaiottfreaug
mherecdmaiottgkemhatcdmaiottkekeyadnecdhabeiolcioelsweaiofioeyhaioyetfallthethsiogncdmaiottfuaccdhabeeiodghhappsioenntua
jecdnmeeteiodghtrsalntuajecdntriogeiodghnrrmtjeepcdhduaioeiodghhpetuajecdhappcalmacnpdtcdrnelwsiothernnhenswcdweelthatst
hdrtncdstprkaklchdrtnthetherperniotthehappsentwpeplefiotioeyennarslchabethekentwebercthsiogthecvdntuajetheuntwebercthsio
gthatyuenaliogthesrmachappsioennlsenwrthnemhyrcthnemhhdrtthnemhhabenearyhefaiofthnemhhabetrsefwriolcthecyaioappreysateth
esuprtaioyewpeplemhhabetdyhefthesrlsbenlbekegsionmsthanuslegrmnmsthajsnnaiofeiofnms that earth ekrsghtentwdtdremsllalmacnke
kanefioawrgtteiopantcdyaiotgiomellsiolswediotslcdletgwcdrpantwasldrenaiofheartayhenmheiocdmerekriocdmereyrcsiogaiofeberc
ioeardiofcdmannuslsioglsbecdrlswenthatmheiocdfsecdretheioemhsnnuslsiogaiofebercioeardiofcdsnyrcsiogpleaneneiofthsnuennag
etthnepeplemhueaionuethsiogtcdtthnemhhabetdyhefcdrlswesioioemacraiothertthnemhuajecdnuslemheiocdreallcioeefsttthnethatua
jecdneethekrsghternsfewthsiognmheiocdarereallcfmiotthnemhcdmaiottlettheujiomthatcdappreysatethesrwrseiofnhspaiofswcdfiot
fiotmrrciothsiogkafmsllhappeiotcdcdmsllvdntusnndtiothepprtdiostctkrsghteionueioenfacmsththsnuennage

我们发现里面有are、that、earth等单词,按照这个思路继续猜测尝试,

已经得到的单词,给我们的信息一方面是字母表,一方面是分词,比如我们知道当前的cd是某个单词的开头,因为cd出现在that后面,当然,cd应该不准。

我们发现后面有2个hat,后面刚好是cd,也就是说这是一个以hat结尾的单词,我们猜测这是what,即把m换成w,

于是字母表变成T2=rltwcqmaefgxzvnhksjidybupo,

标黄的表示这些对应的字母应该都是对的,后面在逐步调整字母表的过程中,这些对应字母不动

重新翻译:

there are ppeiotnsiolsgewheiocdpsnnnpeioenpdyh that cdvdntwaiottmsyjthepgrpcdrureapnaiouhdfthepgrrealureap what cdwaiottureapf
where cdwaiottfke what cdwaiottkekeyadnecdhabeiolcioelsgeaiouioeyhaioyetuallthethsiofncdwaiottupaccdhabeeiodfhhammsioenntpa
jecdnweeteiodfhtrsalntpajecdntriofeiodfhnrrwtjeemcdhdpaioeiodfhhmetpajecdhammcalwacnmdtcdrnelgsiothernnhensgcdgeelthatst
hdrtncdstmrkaklchdrtnthethermerniotthehammsentgmemleuiotioeyennarslchabethekentgebercthsiofthecvdntpajethepntgebercthsio
fthatypenaliofthesrwachammsioennlsengrthnewhyrcthnewhhdrtthnewhhabenearyheuaiouthnewhhabetrseugriolcthecyaioammreysateth
espmrtaioyegmemlewhhabetdyheuthesrlsbenlbekefsionwsthanpslefrwnwsthajsnnaioueiounwsthatearthekrsfhtentgdtdrewsllalwacnke
kaneuioagrftteiomantcdyaiotfiowellsiolsgediotslcdletfgcdrmantgasldrenaiouheartayhenwheiocdwerekriocdwereyrcsiofaioueberc
ioeardioucdwannpslsioflsbecdrlsgenthatwheiocdusecdretheioewhsnnpslsiofaiouebercioeardioucdsnyrcsiofmleaneneiouthsnpennaf
etthnememlewhpeaionpethsioftcdtthnewhhabetdyheucdrlsgesioioewacraiothertthnewhpajecdnpslewheiocdreallcioeeusttthnethatpa
jecdneethekrsfhternsuegthsiofnwheiocdarereallcuwiotthnewhcdwaiottletthepjiowthatcdammreysatethesrgrseiounhsmaiousgcduiot
uiotwrrciothsiofkauwsllhammeiotcdcdwsllvdntpsnndtiothemmrtdiostctkrsfhteionpeioenuacwsththsnpennafe

于是出现了where,而且后面又是cd,说明我们的猜测很合理。

但是,后面出现了2个cd were,这里有点问题,经确认,这是一个乌龙,

上面提到的某个未知的字母表缺了字母o,导致原文中的o在译文里面直接没了,而且字母表里面有个字母重复了,导致原文的某个字母变成译文中的2个字母。

因为这2个字母一定是一起出现的,不可能单独出现,所以数量也一定是一样的,根据字母数量统计可以发现,这2个字母是cw,也就是说cw是对应一个字母。

我们把w去掉,得到新的密文:

lermrtmrvvrclqacxakrsercgfvaqqqvrcrqvfjeletlgfbfqlstcllzajylervkmvgfmnmrtvqtcnefhlervkmmrtxnmrtvsetlgfstcllnmrtvh
sermrgfstcllhdrsetlgfstclldrdrjtfqrgfetircxgcrxakrtcncrjetcjrlntxxlerleachqgfstcllnvtggfetirrcfheetzzacrqqlvt
yrgfqsrrlrcfhelmatxqlvtyrgfqlmchrcfheqmmslyrrzgfefvtcrcfheezrlvtyrgfetzzgtxstgqzflgfmqrxkaclermqqerqakgfkrrxletlal
efmlqgfalzmdtdxgefmlqlerlermzrmqclleretzzarqlkzrzxrnclcrjrqqtmaxgetirlerdrqlkrirmgleachlergbfqlvtyrlervqlkrirmgleac
hletljvrqtxchleramstgetzzacrqqxarqkmleqrsejmgleqrseefmlleqrseetirqrtmjerntcnleqrseetirlmarnkmcxglergjtctzzmrjatlrle
ravzmltcjrkzrzxrseetirlfjernleramxairqxirdrhacqsaletqvaxrhmsqsaletyaqqtcnrcnqsaletlrtmlerdmahelrqlkflfmrsaxxtxstgqdr
dtqrnctkmhllrcztqlgfjtclhcsrxxacxakrfclaxgfxrlhkgfmztqlktaxfmrqtcnertmltjerqsercgfsrmrdmcgfsrmrjmgachtcnrirmg
crtmfcngfstqqvaxachxairgfmxakrqletlsercgfnargfmrlercrseaqqvaxachtcnrirmgcrtmfcngfaqjmgachzxrtqrqrcnleaqvrqqth
rlleqrzrzxrsevrtcqvrleachlgflleqrseetirlfjerngfmxakraccrstgmtclermlleqrsevtyrgfqvaxrsercgfmrtxxgcrrnallleqrletlvt
yrgfqrrlerdmahelrmqanrkleachqsercgftmrmrtxxgnsclleqrsegfstcllxrllervycsletlgftzzmrjatlrleramkmarcnqeaztcnakgfncl
nclsmmgcleachdtnsaxxetzzrclgfgfsaxxbfqlvaqqflclerzzmlfcalgldmahelrcqvrcrqntgsaleleaqvrqqthr

然后我们把T1里面的o和T2里面的w去掉,其他字母顺移,刚好当前的o和w就是对应的,也可以不去掉,留着也行。

PS:这纯属巧合,并没有什么原因。

重新翻译:

thereareppeitnsilsgewheicdpsnnnpeienpdyh that cd vdntwaittmsyjthepgrpcdrureapnaiuhdfthepgrrealureapwhatcdwaittureapfwherecd
waittfkewhatcdwaittkekeyadnecdhabeilcielsgeaiuieyhaiyetuallthethsifncdwaittupaccdhabeeidfhhammsienntpajecdnweeteidfhtrsa
lntpajecdntrifeidfhnrrwtjeemcdhdpaieidfhhmetpajecdhammcalwacnmdtcdrnelgsithernnhensgcdgeelthatsthdrtncdstmrkaklchdrtnthe
thermernitthehammsentgmemleuitieyennarslchabethekentgebercthsifthecvdntpajethepntgebercthsifthatypenalifthesrwachammsien
nlsengrthnewhyrcthnewhhdrtthnewhhabenearyheuaiuthnewhhabetrseugrilcthecyaiammreysatethespmrtaiyegmemlewhhabetdyheuthesrl
sbenlbekefsinwsthanpslefrwnwsthajsnnaiueiunwsthatearthekrsfhtentgdtdrewsllalwacnkekaneuiagrftteimantcdyaitfiwellsilsgedi
tslcdletfgcdrmantgasldrenaiuheartayhenwhei cd were kri cd were yrcsifaiuebercieardiucdwannpslsiflsbecdrlsgenthatwheicdusecdret
heiewhsnnpslsifaiuebercieardiucdsnyrcsifmleaneneiuthsnpennafetthnememlewhpeainpethsiftcdtthnewhhabetdyheucdrlsgesiiewacr
aithertthnewhpajecdnpslewheicdreallcieeusttthnethatpajecdneethekrsfhternsuegthsifnwheicdarereallcuwitthnewhcdwaittletthe
pjiwthatcdammreysatethesrgrseiunhsmaiusgcduituitwrrcithsifkauwsllhammeitcdcdwsllvdntpsnndtithemmrtdistctkrsfhteinpeienua
cwsththsnpennafe

这里的cd其实是少了一个字母,原文是三个字母,而且其中有o,所以这个单词应该是you,也就是说c对应y,d对应u

也就是说密文中的g对应y,密文中的f对应u,

生成新的字母表T2=rltwcqmaexzvnhfkjsgidybupo

重新翻译:

there are lleitnsidsfewheiyulsnnnleienlugh that yu vuntwaittcsgjthelfrl yur mrealnaimhupthelfrreadmrealwhatyuwaittmrealpwhereyu
waittpkewhatyuwaittkekegauneyuhabeidyiedsfeaimieghaigetmaddthethsipnyuwaittmlayyuhabeeiuphhaccsienntlajeyunweeteiuphtrsa
dntlajeyuntripeiuphnrrwtjeecyuhulaieiuphhcetlajeyuhaccyadwayncut yur nedfsithernnhensfyufeedthatsthurtnyustcrkakdyhurtnthe
thercernitthehaccsentfcecdemitiegennarsdyhabethekentfeberythsiptheyvuntlajethelntfeberythsipthatglenadipthesrwayhaccsien
ndsenfrthnewhgrythnewhhurtthnewhhabenearghemaimthnewhhabetrsemfridytheygaiaccregsatetheslcrtaigefcecdewhhabetughemthesrd
sbendbekepsinwsthanlsdeprwnwsthajsnnaimeimnwsthatearthekrsphtentfuturewsddadwaynkekanemiafrptteicantyugaitpiweddsidsfeui
tsdyudetpf yur cantfasdurenaimheartaghenwhei yu were kri yu were grysipaimeberyiearuimyuwannlsdsipdsbe yur dsfenthatwheiyumse yur et
heiewhsnnlsdsipaimeberyiearuimyusngrysipcdeaneneimthsnlennapetthnececdewhleainlethsiptyutthnewhhabetughem yur dsfesiiewayr
aithertthnewhlajeyunlsdewhei yur eaddyieemsttthnethatlajeyuneethekrsphternsmefthsipnwheiyuarereaddymwitthnewhyuwaittdetthe
ljiwthatyuaccregsatethesrfrseimnhscaimsfyumitmitwrryithsipkamwsddhacceityuyuwsddvuntlsnnutitheccrtuistytkrsphteinleienma
ywsththsnlennape

除了一些yu,我们还发现一些yur,显然是your,我们可以在密文对应处补上w,这样我们翻译出来的就是o了

同样的,在一些我们确定是you的那些yu中,对应的密文中也可以添加w,确定的方法就是其他确定的单词提供了分词依据

然后我们继续观察最新的译文,看看由etaorhuwy这几个字母(即字母表对照确定的那些字母,也就是我上面标黄的字母)组成的比较长的字符串都有哪些。

于是我们发现了whei是作为一个单词结尾的,其中whe是确定的,那么显然这应该是when

于是生成新的字母表T2=rltwqcmaexzvnhfkjsgidybupo

重新翻译:

there are llentisndsfewhenyulsiiileneilugh that you vuitwanttcsgjthelfrl your mrealianmhupthelfrreadmreal what you want tmrealpwher
eyouwanttpke what yu want tkekegauieyuhabendynedsfeanmneghangetmaddthethsnpiyuwanttmlayyuhabeenuphhaccsneiitlajeyuiweetenuph
trsaditlajeyuitrnpenuphirrwtjeecyuhulanenuphhcetlajeyuhaccyadwayicut your iedfsntheriiheisfyufeed that sthurtiyustcrkakdyhur
tithethercerintthehaccseitfcecdemntnegeiiarsdyhabethekeitfeberythsnptheyvuitlajethelitfeberythsnp that gleiadnpthesrwayhac
csneiidseifrthiewhgrythiewhhurtthiewhhabeiearghemanmthiewhhabetrsemfrndytheyganaccregsatetheslcrtangefcecdewhhabetughemt
hesrdsbeidbekepsniwsthailsdeprwiwsthajsiianmenmiws that earthekrsphteitfuturewsddadwayikekaiemnafrpttencaityugantpnweddsnd
sfeuntsdyudetpf your caitfasdureianmheartagheiwhenyuwerekrnyuweregrysnpanmeberynearunmyuwaiilsdsnpdsbe your dsfei that when yu m
se your ethenewhsiilsdsnpanmeberynearunmyusigrysnpcdeaieienmthsileiiapetthiececdewhleanilethsnptyutthiewhhabetughem your dsf
esnnewayranthertthiewhlajeyuilsde when you readdy neemsttthiethatlajeyuieethekrsphterismefthsnpiwhenyuarereaddymwntthiewhyuw
anttdettheljnwthatyuaccregsatethesrfrsenmihscanmsfyumntmntwrrynthsnpkamwsddhaccentyuyuwsddvuitlsiiutntheccrtunstytkrspht
enileneimaywsththsileiiape

我们又发现了2个新的单词ethenewh、readdy,其中ethenewh应该是需要填充o才能解释,不过还是想不出来,

而readdy并不是单词,ready才是单词,really才是单词,所以我们把d换成l

生成新的字母表T2=rltwqcmaezvxnhfkjsgidybupo

重新翻译:

thereareccentisnlsfewhenyucsiiiceneicughthatyouvuitwanttdsgjthecfrcyourmreacianmhupthecfrrealmreacwhatyouwanttmreacpwher
eyouwanttpkewhatyuwanttkekegauieyuhabenlynelsfeanmneghangetmallthethsnpiyuwanttmcayyuhabeenuphhaddsneiitcajeyuiweetenuph
trsalitcajeyuitrnpenuphirrwtjeedyuhucanenuphhdetcajeyuhaddyalwayidutyourielfsntheriiheisfyufeelthatsthurtiyustdrkaklyhur
tithetherderintthehaddseitfdedlemntnegeiiarslyhabethekeitfeberythsnptheyvuitcajethecitfeberythsnpthatgceialnpthesrwayhad
dsneiilseifrthiewhgrythiewhhurtthiewhhabeiearghemanmthiewhhabetrsemfrnlytheyganaddregsatethescdrtangefdedlewhhabetughemt
hesrlsbeilbekepsniwsthaicsleprwiwsthajsiianmenmiwsthatearthekrsphteitfuturewsllalwayikekaiemnafrpttendaityugantpnwellsnl
sfeuntslyuletpfyourdaitfaslureianmheartagheiwhenyuwerekrnyuweregrysnpanmeberynearunmyuwaiicslsnplsbe your lsfei that when yu

mse your ethenewhsiicslsnpanmeberynearunmyusigrysnpdleaieienmthsiceiiapetthiededlewhceanicethsnptyutthiewhhabetughem your

lsfe snnewayranthertthiewhcajeyuicsle when you really neemsttthiethatcajeyuieethekrsphterismefthsnpiwhenyuarereallymwntthiewhyuw
anttletthecjnwthatyuaddregsatethesrfrsenmihsdanmsfyumntmntwrrynthsnpkamwsllhaddentyuyuwsllvuitcsiiutntheddrtunstytkrspht
eniceneimaywsththsiceiiape

于是我们注意到,有lsfei和lsfe这2个单词,其中i和s刚好是T1中的未确定的字母中最前面的2个。

于是我们想到,其实i和s反了,这应该是life和lifes,虽然lifes并不是单词,但是可以拆开,s变成so,这里是一个词组so that

生成新的字母表T2=rltwacmqezvxnhfkjsgidybupo

重新翻译:

thereareccents in life when yu cissscenescugh that you vust want tdigjthecfrcyourmreacsanmhupthecfrrealmreacwhatyouwanttmreacpwher
eyouwanttpkewhatyuwanttkekegauseyuhabenlynelifeanmneghangetmallthethinpsyuwanttmcayyuhabeenuphhaddinesstcajeyusweetenuph
trialstcajeyustrnpenuphsrrwtjeedyuhucanenuphhdetcajeyuhaddyalwaysdutyourselfinthersshesifyufeelthatithurtsyuitdrkaklyhur
tsthetherdersntthehaddiestfdedlemntnegessarilyhabethekestfeberythinptheyvustcajethecstfeberythinpthatgcesalnptheirwayhad
dinessliesfrthsewhgrythsewhhurtthsewhhabesearghemanmthsewhhabetriemfrnlytheyganaddregiatetheicdrtangefdedlewhhabetughemt
heirlibeslbekepinswithascileprwswithajissanmenmswithatearthekriphtestfuturewillalwayskekasemnafrpttendastyugantpnwellinl
ifeuntilyuletpfyourdastfailuresanmheartagheswhenyuwerekrnyuweregryinpanmeberynearunmyuwasscilinplibe your life s that when yu m
ieyourethenewhisscilinpanmeberynearunmyuisgryinpdleasesenmthiscessapetthsededlewhceanscethinptyutthsewhhabetughem your life innewayranthertthsewhcajeyuscilewhenyoureallyneemittthsethatcajeyuseethekriphtersimefthinpswhenyuarereallymwntthsewhyuw
anttletthecjnwthatyuaddregiatetheirfrienmshidanmifyumntmntwrrynthinpkamwillhaddentyuyuwillvustcissutntheddrtunitytkripht
enscenesmaywiththiscessape

于是我们又发现了vust这个单词,把v换成j,

生成新的字母表T2=rltwacmqezvxnhfkjsgidbyupo

重新翻译:

there are ccentsinlife when yu ciss scenes cugh that you just want tdigv the cfrc your mreacsanmhup the cfrrealmreac what you want tmreacp

where you want tpke what yu want tkekegause yu habenlyne life anmneghangetmallthethinps yu want tmcay yu habeenuphhaddinesst cave yusweetenuph
trialst cave yustrnpenuphsrrwtveedyuhucanenuphhdet cave yuhaddyalwaysdutyourselfinthersshesifyufeelthatithurtsyuitdrkaklyhur
tsthetherdersntthehaddiestfdedlemntnegessarilyhabethekestfeberythinptheyjust cave thecstfeberythinpthatgcesalnptheirwayhad
dinessliesfrthsewhgrythsewhhurtthsewhhabesearghemanmthsewhhabetriemfrnlytheyganaddregiatetheicdrtangefdedlewhhabetughemt
heirlibeslbekepinswithascileprwswithavissanmenmswithatearthekriphtestfuturewillalwayskekasemnafrpttendastyugantpnwellinl
ifeuntilyuletpfyourdastfailuresanmheartagheswhenyuwerekrnyuweregryinpanmeberynearunmyuwasscilinplibeyourlifesthatwhenyum
ieyourethenewhisscilinpanmeberynearunmyuisgryinpdleasesenmthiscessapetthsededlewhceanscethinptyutthsewhhabetughemyourlif
einnewayranthertthsewh cave yuscilewhenyoureallyneemittthsethat cave yu see the kriphtersimefthinps when yu are really mwntthse wh yu

want tletthecvnwthatyuaddregiatetheirfrienmshidanmifyumntmntwrrynthinpkamwillhaddentyuyuwilljustcissutntheddrtunitytkripht
en scenes may with thiscessape

于是我们发现scenes出现了2次,cave出现了6次,

现在,etaoinrshuwyj这几个字母是确定的,dclmpfgbkvxqz这几个字母是不确定的,

也就是说,cave其实是*a*e,而且2个字母应该分别在dclmpfgbkvxqz中c的附近和v的附近,很快我们就锁定了make

生成新的字母表T2=rltwacmqezxnvhfkjsgiybdupo

注意,哪些字母是确定的不要标错了,不然很影响判断的

重新翻译:

therearemmentsincifewhenyumisssmenesmughthatyoujustwanttdigkthemfrmyourlreamsanlhupthemfrreaclreamwhatyouwanttlreampwher
eyouwanttpvewhatyuwanttvevegauseyuhabencynecifeanlneghangetlaccthethinpsyuwanttlmayyuhabeenuphhaddinesstmakeyusweetenuph
triacstmakeyustrnpenuphsrrwtkeedyuhumanenuphhdetmakeyuhaddyacwaysdutyoursecfinthersshesifyufeecthatithurtsyuitdrvavcyhur
tsthetherdersntthehaddiestfdedcelntnegessaricyhabethevestfeberythinptheyjustmakethemstfeberythinpthatgmesacnptheirwayhad
dinessciesfrthsewhgrythsewhhurtthsewhhabesearghelanlthsewhhabetrielfrncytheyganaddregiatetheimdrtangefdedcewhhabetughelt
heircibescbevepinswithasmiceprwswithakissanlenlswithatearthevriphtestfuturewiccacwaysvevaselnafrpttendastyugantpnweccinc
ifeunticyucetpfyourdastfaicuresanlheartagheswhenyuwerevrnyuweregryinpanleberynearunlyuwassmicinpcibeyourcifesthatwhenyul
ieyourethenewhissmicinpanleberynearunlyuisgryinpdceasesenlthismessapetthsededcewhmeansmethinptyutthsewhhabetughelyourcif
einnewayranthertthsewhmakeyusmicewhenyoureaccyneelittthsethatmakeyuseethevriphtersilefthinpswhenyuarereaccylwntthsewhyuw
anttcetthemknwthatyuaddregiatetheirfrienlshidanlifyulntlntwrrynthinpvalwicchaddentyuyuwiccjustmissutntheddrtunitytvripht
ensmeneslaywiththis messape

很明显最后这个应该是message,把p换成g

生成新的字母表T2=rltwacmqezxnvkfjhsgiybdupo

重新翻译:

therearemmentsincipewhenyu miss smenes mufhthatyoujustwanttdifkthemprmyourlreamsanlhugthemprreaclreamwhatyouwanttlreamgwher
eyouwanttgvewhatyuwanttvevefauseyuhabencynecipeanlnefhanfetlaccthethingsyuwanttlmayyuhabeenughhaddinesstmakeyusweetenugh
triacstmakeyustrngenughsrrwtkeedyuhumanenughhdetmakeyuhaddyacwaysdutyoursecpinthersshesipyupeecthatithurtsyuitdrvavcyhur
tsthetherdersntthehaddiestpdedcelntnefessaricyhabethevestpeberythingtheyjustmakethemstpeberythingthatfmesacngtheirwayhad
dinessciesprthsewhfrythsewhhurtthsewhhabesearfhelanlthsewhhabetrielprncytheyfanaddrefiatetheimdrtanfepdedcewhhabetufhelt
heircibescbeveginswithasmicegrwswithakissanlenlswithatearthevrightestputurewiccacwaysvevaselnaprgttendastyufantgnweccinc
ipeunticyucetgpyourdastpaicuresanlheartafheswhenyuwerevrnyuwerefryinganleberynearunlyuwassmicingcibeyourcipesthatwhenyul
ieyourethenewhissmicinganleberynearunlyuisfryingdceasesenlthismessagetthsededcewhmeansmethingtyutthsewhhabetufhelyourcip
einnewayranthertthsewhmakeyusmicewhenyoureaccyneelittthsethatmakeyuseethevrightersilepthingswhenyuarereaccylwntthsewhyuw
anttcetthemknwthatyuaddrefiatetheirprienlshidanlipyulntlntwrrynthingvalwicchaddentyuyuwiccjustmissutntheddrtunitytvright
en smenes lay with this message

现在发现lay这个单词,对照字母表,应该是day,把l换成d

生成新的字母表T2=rltwacmqenzxvkfjhsgiybdupo

重新翻译:

there are mment sinlipe when yu miss smenes mufh thatyoujustwanttcifkthemprmyourdreamsandhugthemprrealdreamwhatyouwanttdreamgwher
eyouwanttgvewhatyuwanttvevefauseyuhabenlynelipeandnefhanfetdallthethingsyuwanttdmayyuhabeenughhaccinesstmakeyusweetenugh
trialstmakeyustrngenughsrrwtkeecyuhumanenughhcetmakeyuhaccyalwayscutyourselpinthersshesipyupeelthatithurtsyuitcrvavlyhur
tsthethercersntthehacciestpcecledntnefessarilyhabethevestpeberythingtheyjustmakethemstpeberythingthatfmesalngtheirwayhac
cinessliesprthsewhfrythsewhhurtthsewhhabesearfhedandthsewhhabetriedprnlytheyfanaccrefiatetheimcrtanfepceclewhhabetufhedt
heirlibeslbeveginswithasmilegrwswithakissandendswithatearthevrightestputurewillalwaysvevasednaprgttencastyufantgnwellinl
ipeuntilyuletgpyourcastpailuresandheartafheswhenyuwerevrnyuwerefryingandeberynearundyuwassmilinglibeyourlipesthatwhenyud
ieyourethenewhissmilingandeberynearundyuisfryingcleasesendthismessagetthsececlewhmeansmethingtyutthsewhhabetufhedyourlip
einnewayranthertthsewhmakeyusmilewhenyoureallyneedittthsethatmakeyuseethevrightersidepthingswhenyuarereallydwntthsewhyuw
anttletthemknwthatyuaccrefiatetheirpriendshicandipyudntdntwrrynthingvadwillhaccentyuyuwilljustmissutntheccrtunitytvright
en smenes day with this message

现在发现mufh这个单词,对照字母表,应该是much,把f换成c

生成新的字母表T2=rltwacmqenjzvxfkhsgiybdupo

重新翻译:

there are mmentsinpifewhenyumisssmenesmuchthatyoujustwanttlickthemfrmyourdreamsandhugthemfrreapdreamwhatyouwanttdreamgwher
eyouwanttgvewhatyuwanttvevecauseyuhabenpynepifeandnechancetdappthethingsyuwanttdmayyuhabeenughhallinesstmakeyusweetenugh
triapstmakeyustrngenughsrrwtkeelyuhumanenughhletmakeyuhallyapwayslutyoursepfinthersshesifyufeepthatithurtsyuitlrvavpyhur
tsthetherlersntthehalliestflelpedntnecessaripyhabethevestfeberythingtheyjustmakethemstfeberythingthatcmesapngtheirwayhal
linesspiesfrthsewhcrythsewhhurtthsewhhabesearchedandthsewhhabetriedfrnpytheycanallreciatetheimlrtanceflelpewhhabetuchedt
heirpibespbeveginswithasmipegrwswithakissandendswithatearthevrightestfuturewippapwaysvevasednafrgttenlastyucantgnweppinp
ifeuntipyupetgfyourlastfaipuresandheartacheswhenyuwerevrnyuwerecryingandeberynearundyuwassmipingpibeyourpifesthatwhenyud
ieyourethenewhissmipingandeberynearundyuiscryinglpeasesendthismessagetthselelpewhmeansmethingtyutthsewhhabetuchedyourpif
einnewayranthertthsewhmakeyusmipewhenyoureappyneedittthsethatmakeyuseethevrightersidefthingswhenyuarereappydwntthsewhyuw
anttpetthemknwthatyuallreciatetheirfriendshilandifyudntdntwrrynthingvadwipphallentyuyuwippjustmissutnthellrtunitytvright
ensmenesdaywiththismessage

此时,我突然发现之前的life又变成了pife,原来是之前标注漏了,导致后面字母表变换的时候一直错误。

现在改回来,新的字母表T2=rltwacmqenjxvzfkhsgiybdupo

重新翻译:

there are mments in life when yu miss smenes much that you just want t pick them frm your dream sandhug them fr real dream

what you want t dream g where you wanttgve what yu want tve vecause yuhabenlynelifeandnechancetdallthethings

yuwanttdmayyuhabeenughhappinesstmakeyusweetenughtrialstmakeyustrngenughsrrwtkeepyuhumanenughhpetmakeyuhappyalwaysputyourselfinthersshesifyufeelthatithurtsyuitprvavlyhurtsthetherpersntthehappiestfpepledntnecessarilyhabethevestfeberythingtheyjustmakethemstfeberythingthatcmesalngtheirwayhap
pinessliesfrthsewhcrythsewhhurtthsewhhabesearchedandthsewhhabetriedfrnlytheycanappreciatetheimprtancefpeplewhhabetuchedt
heirlibeslbeveginswithasmilegrwswithakissandendswithatearthevrightestfuturewillalwaysvevasednafrgttenpastyucantgnwellinl
ifeuntilyuletgfyourpastfailuresandheartacheswhenyuwerevrnyuwerecryingandeberynearundyuwassmilinglibeyourlifesthatwhenyud
ieyourethenewhissmilingandeberynearundyuiscryingpleasesendthismessagetthsepeplewhmeansmethingtyutthsewhhabetuchedyourlif
einnewayranthertthsewhmakeyusmilewhenyoureallyneedittthsethatmakeyuseethevrightersidefthingswhenyuarereallydwntthsewhyuw
anttletthemknwthatyuappreciatetheirfriendshipandifyudntdntwrrynthingvadwillhappentyuyuwilljustmissutnthepprtunitytvright
ensmenesdaywiththismessage

同理,vecause是because,生成新的字母表T2=rltwacmqenjxvzfkhsgdybiupo

重新翻译:

therearemmentsinlifewhenyumisssmenesmuchthatyoujustwanttpickthemfrmyourdreamsandhugthemfrrealdreamwhatyouwanttdreamgwher
eyouwanttgbewhatyuwanttbebecauseyuhavenlynelifeandnechancetdallthethingsyuwanttdmayyuhaveenughhappinesstmakeyusweetenugh
trialstmakeyustrngenughsrrwtkeepyuhumanenughhpetmakeyuhappyalwaysputyourselfinthersshesifyufeelthatithurtsyuitprbablyhur
tsthetherpersntthehappiestfpepledntnecessarilyhavethebestfeverythingtheyjustmakethemstfeverythingthatcmesalngtheirwayhap
pinessliesfrthsewhcrythsewhhurtthsewhhavesearchedandthsewhhavetriedfrnlytheycanappreciatetheimprtancefpeplewhhavetuchedt
heirliveslvebeginswithasmilegrwswithakissandendswithatearthebrightestfuturewillalwaysbebasednafrgttenpastyucantgnwellinl
ifeuntilyuletgfyourpastfailuresandheartacheswhenyuwerebrnyuwerecryingandeverynearundyuwassmilingliveyourlifesthatwhenyud
ieyourethenewhissmilingandeverynearundyuiscryingpleasesendthismessagetthsepeplewhmeansmethingtyutthsewhhavetuchedyourlif
einnewayranthertthsewhmakeyusmilewhenyoureallyneedittthsethatmakeyuseethebrightersidefthingswhenyuarereallydwntthsewhyuw
anttletthemknwthatyuappreciatetheirfriendshipandifyudntdntwrrynthingbadwillhappentyuyuwilljustmissutnthepprtunitytbright
ensmenesdaywiththismessage

至此,破解结束。

把上文整理一下:

there are mments in life when yu miss smenes much that you just want t pick them frm your dreams and hug them fr real dream what you want t dream

g where you want t g be what yu want t be because yu have nly ne life and ne chance t d all the things yu want t d

may yu have enugh happiness t make yu sweet enugh trials t make yu strngenughsrrw t keep yu human enughhpe t make yu happy

always put yourself in thers shes if yu feel that it hurts yu it prbably hurts the ther persnt the happies tf peple dnt necessarily have the best f everything they

just make the mst feverything thatcmesalng theirway happiness liesfrthse wh cry thsewhhurtthsewh

have searched and thsewhhavetriedfrnly they can appreciate the imprtancef peple whhavetuched

their lives lve begins with a smile grwswith akiss and ends with at earth ebrightestfuture will always

be based nafrgttenpastyucantgn well in life untilyuletgf your pastfailures and heartaches

when yu were brnyu were crying andeverynearundyuwassmilinglive your lifes that whenyudie youre the ne wh is smiling and everyne arund yu iscrying

please send this message t thse peple wh mean smething t yu tthsewhhavetuched yourlifeinnewayranthertthsewhmakeyusmile

whenyoureallyneedittthsethatmakeyuseethebrightersidefthingswhenyuarereallydwntthsewhyuwanttletthemknw

thatyu appreciatetheirfriendship and if yu dnt dnt wrry nthing bad will happen t yu yuwill just miss ut n the pprtunity t brighten smenesday with this message

附上原始原文:

There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream;go where you want to go;be what you want to be,because you have only one life and one chance to do all the things you want to do.

  May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’shoes.If you feel that it hurts you,it probably hurts the other person, too.

  The happiest of people don’t necessarily have the best of everything;they just make the most of everything that comes along their way.Happiness lies for those who cry,those who hurt, those who have searched,and those who have tried,for only they can appreciate the importance of people

  who have touched their lives.Love begins with a smile,grows with a kiss and ends with a tear.The brightest future will always be based on a forgotten past, you can’t go on well in lifeuntil you let go of your past failures and heartaches.

  When you were born,you were crying and everyone around you was smiling.Live your life so that when you die,you're the one who is smiling and everyone around you is crying.

  Please send this message to those people who mean something to you,to those who have touched your life in one way or another,to those who make you smile when you really need it,to those that make you see the brighter side of things when you are really down,to those who you want to let them know that you appreciate their friendship.And if you don’t, don’t worry,nothing bad will happen to you,you will just miss out on the opportunity to brighten someone’s day with this message.

去掉空格和空行:

Therearemomentsinlifewhenyoumisssomeonesomuchthatyoujustwanttopickthemfromyourdreamsandhugthemforreal!Dreamwhatyouwanttodream;gowhereyouwanttogo;bewhatyouwanttobe,becauseyouhaveonlyonelifeandonechancetodoallthethingsyouwanttodo.Mayyouhaveenoughhappinesstomakeyousweet,enoughtrialstomakeyoustrong,enoughsorrowtokeepyouhuman,enoughhopetomakeyouhappy?Alwaysputyourselfinothers’shoes.Ifyoufeelthatithurtsyou,itprobablyhurtstheotherperson,too.Thehappiestofpeopledon’tnecessarilyhavethebestofeverything;theyjustmakethemostofeverythingthatcomesalongtheirway.Happinessliesforthosewhocry,thosewhohurt,thosewhohavesearched,andthosewhohavetried,foronlytheycanappreciatetheimportanceofpeoplewhohavetouchedtheirlives.Lovebeginswithasmile,growswithakissandendswithatear.Thebrightestfuturewillalwaysbebasedonaforgottenpast,youcan’tgoonwellinlifeuntilyouletgoofyourpastfailuresandheartaches.Whenyouwereborn,youwerecryingandeveryonearoundyouwassmiling.Liveyourlifesothatwhenyoudie,you'retheonewhoissmilingandeveryonearoundyouiscrying.Pleasesendthismessagetothosepeoplewhomeansomethingtoyou,tothosewhohavetouchedyourlifeinonewayoranother,tothosewhomakeyousmilewhenyoureallyneedit,tothosethatmakeyouseethebrightersideofthingswhenyouarereallydown,tothosewhoyouwanttoletthemknowthatyouappreciatetheirfriendship.Andifyoudon’t,don’tworry,nothingbadwillhappentoyou,youwilljustmissoutontheopportunitytobrightensomeone’sdaywiththismessage.

用上面的语料处理器,把语料变成纯英文小写字母:

therearemomentsinlifewhenyoumisssomeonesomuchthatyoujustwanttopickthemfromyourdreamsandhugthemforrealdreamwhatyouwanttod
reamgowhereyouwanttogobewhatyouwanttobebecauseyouhaveonlyonelifeandonechancetodoallthethingsyouwanttodomayyouhaveenoughh
appinesstomakeyousweetenoughtrialstomakeyoustrongenoughsorrowtokeepyouhumanenoughhopetomakeyouhappyalwaysputyourselfinot
hersshoesifyoufeelthatithurtsyouitprobablyhurtstheotherpersontoothehappiestofpeopledon

PS:早在公元9世纪,就有密码学家掌握了这个方法!

三,生成序列平移法

通讯双方选取一个序列生成函数,如f(x)=x^2+1,由此生成序列2,5,10,17......

依次把每个字母进行平移,平移长度由生成序列给出,这个序列生成函数就是秘钥,这也是对称加密。

加密机:

#include<iostream>
using namespace std;

int f(int n)
{
    return (n*n+1)%26;
}

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)cout << char((s[i] - 'a' + f(i+1)) % 26 + 'a');
    return 0;
}

运行:

love
ntfv

有秘钥的解密机:

#include<iostream>
using namespace std;

int f(int n)
{
    return (n*n+1)%26;
}

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)cout << char((s[i] - 'a' + 26 - f(i+1)) % 26 + 'a');
    return 0;
}

运行:

ntfv
love

无秘钥的破解方案:

通过暴力枚举肯定是不行的,生成序列可以有无穷种,那么,通过频率法试一下?

先看下前面的字母表加密中的2个频率数据:

Algoritmy网站给出的大语料统计频率数据:

z q j x k v b p y g f w m u c l d r h s n i o a t e
0.07% 0.10% 0.15% 0.15% 0.77% 0.98% 1.49% 1.93% 1.97% 2.02% 2.23% 2.36% 2.41% 2.76% 2.78% 4.03% 4.25% 5.99% 6.09% 6.33% 6.75% 6.97% 7.51% 8.17% 9.06% 12.70%

纯英文小写字母语料库

therearemomentsinlifewhenyoumisssomeonesomuchthatyoujustwanttopickthemfromyourdreamsandhugthemforrealdreamwhatyouwanttod
reamgowhereyouwanttogobewhatyouwanttobebecauseyouhaveonlyonelifeandonechancetodoallthethingsyouwanttodomayyouhaveenoughh
appinesstomakeyousweetenoughtrialstomakeyoustrongenoughsorrowtokeepyouhumanenoughhopetomakeyouhappyalwaysputyourselfinot
hersshoesifyoufeelthatithurtsyouitprobablyhurtstheotherpersontoothehappiestofpeopledon

其中的字母统计数据:

z0 x0 q0 j1 v2 b5 k5 c5 f8 d8 g9 l12 w12 i13 p14 m16 y21 r21 s24 n26 u28 h32 a33 t42 e52 o57

我们用加密机加密这个语料,得到:可以看出来,顺序确实很接近,而且数值的比例也差不多。

vmoielprqletbikfrygqenrjpzqzwzsdqbqbgcshgjypfehrddqvlzckwllgxlhxqzleizdcoditwsfwormdyahemvhwwjjbpcervitfcrgyaewbytschiga
vryxgfgmgsgdylwllgxlydptoeegwzunksvuqgosenyhwbqdiwssiblwyfxjnjhjkedzlrgescqtllhbywlkrjviksqjyzsjeklicsgjelwzuykagfptexhs
yctfftghllqnipyfexyfgyoeofeuxoapzhllqnipyfexvsqsqvnzstlpggfdoqsxcpppyzjvofxvnzstlegesigjexcjolrfrqafvnajqcyqqdigkbpsgyok
rjttumyvstdlsrxtsaleeggehlbyuzqzskpcmoeydnvjjqwgfpokrjtqgwcfnembxewwoehfifrzfgotrmgiye

统计数据:

u6 a8 m8 b11 n11 k12 x14 h14 v14 c14 d14 i16 o16 p16 z17 t17 r17 w18 j19 f22 q23 s25 y25 l28 g30 e31

可以看出,分布规律已经不太一样了。

所以,通过频率去推测序列生成函数是不可能的。

看起来,貌似是个比较靠谱的加密算法?然而,虽然没有了全局的频率统计信息,但是还是存在局部的周期信息,还是可以破解的,下文会提到。

四,多密码表加密

以二张密码表替换为例,首先给定二张密码表替换加密的替换密码表:

有了这两行密码表,我们就可以在加密过程中对明文中的第1个字母使用密码表1进行加密,对第2个使用字母使用密码表2进行加密,第3个字母又重新使用密码表1加密,第4个字母使用密码表2,如此重复直到所有明文都被加密。

这样,频率破解法也会失效。

这个多密码表就是秘钥,这还是对称加密。

类似的,可以整出一个有26个密码表的大表,如下是著名的维热纳尔方阵,可以取其前任意多行组成一个多行密码表。

不难发现,维热纳尔方阵其实就是序列生成函数f(x)=x,而任何多项式序列生成函数,都是一个有26个密码表的大表。

虽然没有了全局的频率统计信息,但是,局部的周期信息依然存在,即如果2个单词的下标之差是密码表的数量的整数倍,那么这2个单词机密后的内容就是一样的。

这样,只要能猜出密码表的数量,就可以拆开分别统计字母频率,从而破解。

五,恩尼格玛密码机(Enigma)

1,转子

图片左边是一个完整的转子,右边是一个转子拆开后的零件。

  

转子就是一个字母表映射,导线是用来做字母映射的,也是固定字母表,

但是它是会转的,每做一次映射计算,转子就转动一格。

本质上,转子就是字母表映射g(x)和序列生成函数f(x)=x的复合函数g(f(x))

单个转子的本质和维热纳尔方阵是一样的,周期是26,还是很容易破解。

密码机是可以被敌方截获的,也是可以轻松拆解的,内部构造是透明的,所以单个转子所能提供的加密信息其实是转子当前转到哪一格,也就是只有26种情况。

2,转子组

把3个转子组装到一起,每做一次映射计算,转子A转一格,转子A每转一圈,转子B转一格,转子B每转一圈,转子C转一格。

其实就和时钟里面的机械是一样的,秒针带动分针,分针带动时针。

转子组还可以交换顺序,有6种全排列,所以是26*26*26*6=105456种情况。

在通讯双方都有了恩尼格玛密码机之后,传输信息还需要额外传递密钥,来设定3个转子的顺序、初始位置,这还是一种对称加密。

3,插线板

    

插线板上有26个孔,任意2个孔之间用导线连接起来,就能完成一个字母对换操作。

整个插线板其实也就相当于一个字母表替换,如何插线也是密钥需要包含的信息。

第一期的插线板是有6条导线,所以有C(26,12)*11*9*7*5*3=100391791500种情况

转子组合插线板组合起来,有10^16种情况。

4,反射器

在最后一个转子上,装有一个反射器,它把26个字母分为13组,相当于一个有13根导线的插线板。

反射器是固定不变的,不涉及密钥信息,它的作用是让信号重新传入转子组,再次进行3次字母表替换之后,才得到加密后的字母。

也就是说,转子组每次要完成6次字母表映射,然后转子A才转动一格。

根据http://www.voidcn.com/article/p-uacxadvu-dn.html一文,完整的信号传递过程是:

键盘——插线板——转子A——转子B——转子C——反射器——转子C——转子B——转子A——插线板——显示器

反射器的作用在于,在密码机配置不变的情况下,加密过程和解密过程是一样的操作。

也就是说,在同样的初始配置下,密码机可以把原文转换成密文,也可以把密文转换成原文

换句话说,密码机相当于就是一个时刻变化的反射器。

5,转子组重设操作

密码机的使用过程,操作员会先按照密码本中的记录来设置机器,我们假设这时的转子位置为AOH,之后他会随意打三个字母,假设为EIN,接着为了保险起见,他会将这三个字母重新打一遍。这六个字母会被转换成其它六个字母,这里假设为XHTLOA。最后,操作员会将转子重新设置为EIN,即他一开始打的三个字母,之后输入密电原文。在接收方将信息解密时,他会使用相反的步骤。首先,他也会将转子按照密码本中的记录设置好,然后他就会打入密文中的头六个字母,即XHTLOA,如果发送方操作正确的话,显示板上就会显示EINEIN。这时接收方就会将转子设置为EIN,之后他就可将密电打入而得到原文了。

之所以有这么一个操作,是因为密码机被使用非常多,如果不重设转子组,所有的密文汇聚起来就会提供足够的统计信息,虽然还没有人想出如何破解,但是防患于未然。

6,恩尼格玛密码机的破解

密码机有一些漏洞,成为它被破解的关键。

反射器的漏洞:

漏洞一:任何一个字母,加密之后一定会变成另外一个字母,不可能变成自身。

转子组重设操作的漏洞:

漏洞二:转子设置包含在了密文之中。

漏洞三:这个操作重复了一次,虽然有校验作用,但是使得破解难度极大降低。

漏洞四:本来应该选择三个随机字母,但是因为密码机是被认为无法破解的,所以操作员经常偷懒,用的是键盘上的三个连续字母。

加密系统的保密性只应建立在对密钥的保密上,不应该取决于加密算法的保密

这些操作可以算是整个大的加密算法的一部分,它的保密性不高,很多人都知道,敌方自然也很容易知道,敌方唯一不知道的就是密钥本身。

雷杰夫斯基的破解方案:

收集大量密文,根据每个密文的前六个字母,可以分析出转子组的设定。

后来转子组重设操作被取消了,于是雷杰夫斯基又造了枚举机器,六台机器同时工作,因为运行时声势浩大,机器被称为炸弹。

7,恩尼格玛密码机的升级配置

恩尼格玛密码机虽然足够复杂,但是还是被破解了,于是密码机又被升级了:

转子变成了五选三,新的转子组有105456*10=1054560种情况,

插线板变成了十条,新的插线板有C(26,20)*19*17*15*13*11*9*7*5*3=150738274937250种情况,

组合起来有159 million million million种情况。(《模仿游戏》中,图灵和其他密码学家交流时说的就是这个数字)

密码本示例:

最终,图灵吸收了雷杰夫斯基的思想,造出了更厉害的破解机器,结合其他一些漏洞,最终破解了密码机。

漏洞五:《模仿游戏》中说的是原文经常出现希特勒这个词,一些文章中也提到原文经常提到天气相关的词。

切记,重复是万恶之源

猜你喜欢

转载自blog.csdn.net/nameofcsdn/article/details/114212217