|
1
|
|
|
import random |
|
2
|
|
|
import string |
|
3
|
|
|
import unittest |
|
4
|
|
|
|
|
5
|
|
|
from playfair_cipher import decode, encode |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class Tests(unittest.TestCase): |
|
9
|
|
|
BASIC_TESTS = [ |
|
10
|
|
|
[encode, ["Fizz Buzz is x89 XX.", "checkio101"], 'do2y7mt22kry94y2y2'], |
|
11
|
|
|
[decode, ["do2y7mt22kry94y2y2", "checkio101"], 'fizxzbuzzisx89xzxz'], |
|
12
|
|
|
[encode, ["How are you?", "hello"], 'ea2imb1ht0'], |
|
13
|
|
|
[decode, ["ea2imb1ht0", "hello"], 'howareyouz'], |
|
14
|
|
|
[encode, ["My name is Alex!!!", "alexander"], 'i1dlkxjqlexn'], |
|
15
|
|
|
[decode, ["i1dlkxjqlexn", "alexander"], 'mynameisalex'], |
|
16
|
|
|
[encode, ["Who are you?", "human"], 'rnvftc1jd5'], |
|
17
|
|
|
[decode, ["rnvftc1jd5", "human"], 'whoareyouz'], |
|
18
|
|
|
[encode, ["ATTACK AT DAWN", "general"], 'ewwektewhnua'], |
|
19
|
|
|
[decode, ["ewwektewhnua", "general"], 'attackatdawn'], |
|
20
|
|
|
] |
|
21
|
|
|
|
|
22
|
|
|
ENCODE_TESTS = [ |
|
23
|
|
|
[ |
|
24
|
|
|
encode, |
|
25
|
|
|
[ |
|
26
|
|
|
"Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country", |
|
27
|
|
|
"42", |
|
28
|
|
|
], |
|
29
|
|
|
'g2xl2s4yg64hijpbznk3luapu0tzcgmtg2xlulnsifiutousjftqpl2mgcbm4dpoummbtzgcznfqfkjuhqif2nhobvfwutqgmds2qhbvifxmjufjthl0plsgqlymulqjufhisbrzzni4mctulizngqgkbmuhau2m2shfm2mhschfuig4mbys2mrxjufqmbkg21cv4jlhmpyqazznfjvlm24ibmavvokmjfugqzhunzifkh4iryygsxqfhfof2mgchugudm2sb4gugkbsoiiutousz0', |
|
30
|
|
|
], |
|
31
|
|
|
[ |
|
32
|
|
|
encode, |
|
33
|
|
|
[ |
|
34
|
|
|
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.", |
|
35
|
|
|
"checkio", |
|
36
|
|
|
], |
|
37
|
|
|
'rcnoqhlvtnjerclxhwblhuhclukhuhuvonbfkqcwhoqdcnhwdcuddlhcrtrhjeqcdwslidhujercljducdpnlyyl', |
|
38
|
|
|
], |
|
39
|
|
|
[ |
|
40
|
|
|
encode, |
|
41
|
|
|
[ |
|
42
|
|
|
"One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.", |
|
43
|
|
|
"goodmorming", |
|
44
|
|
|
], |
|
45
|
|
|
'gacrdifghnspfaoinrditngvetdjfnidovid0kpciumifbgvpnaisbgkgrwnqcwobaxndircmghsgxcfmgasajjgiwigckcwperghscpnzgaqgtnirdtmpdqfcbejbbgfqpnqmaxbrqgysfbobqmusvjnpfedtkmwnnpgxedrtaccph1vhgojsh1mdrcobbgmgxmrbbkznmepnxgasgtxoq3nxfexogatupncfiumghnteyseomkznckawmamtpeoxbagufwcrbrepbozsgtqmrbianbh4rdrcas', |
|
46
|
|
|
], |
|
47
|
|
|
[ |
|
48
|
|
|
encode, |
|
49
|
|
|
["The quick, brown fox jumps over a lazy dog.", "nobody"], |
|
50
|
|
|
'vfikwgejntasbcnzmrpqzeshwnqb2oybe1', |
|
51
|
|
|
], |
|
52
|
|
|
[ |
|
53
|
|
|
encode, |
|
54
|
|
|
[ |
|
55
|
|
|
"A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now. When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary", |
|
56
|
|
|
"xyzqwerty", |
|
57
|
|
|
], |
|
58
|
|
|
'czpokdfl4u3ddxohgtnhmddhzssple3dleokpolivtzsbgdxlp4uofsdagd3d3exydnpalhokmlilsbfmhzjjbijzsipzegbgnzeinsxkzbtbgtnrnpozdsakxxsagwdnhtllixykodypaqkmaijlelsmbzjjbjzdndtzddyrklbagqdoflelpkll1mlofsdogszhbnlnicnmwvtkdbtlfkqsalpbclptcdkhoagxyxyx1kogbd3zs3dlisydxath0x1foxykodypaydnhbgszfmwdgvtgrnzsdmkoin4urcqkpacnbcsxlirtczhohtokmhsxmdblsdbaagwsdx3dmanpsymah0teydjgxyxsagbahoy3xdzcndftzddytbtakoryagh0opeyzjzszjfoydkzmp3ymx0tursxtgxyyspegbg0cnl1tbbl0ltszdsaagysxdkbhbol0lmdbfsdmdkz2lswdl4fhrdwliagqknszsydtbroxkpmhbkylivtatxyd3h0rcvrrhxemdtbtmsxtnlemdzdofmambkzhoszdlh0da0rtx', |
|
59
|
|
|
], |
|
60
|
|
|
[ |
|
61
|
|
|
encode, |
|
62
|
|
|
[ |
|
63
|
|
|
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure", |
|
64
|
|
|
"nobody", |
|
65
|
|
|
], |
|
66
|
|
|
'dtwfu1tuczqmiqbrbadsey3ij0t0icukewwbskacognbgbcodscjcahmkfowvsiooyjviqwedcqyca3itonsonoyq3fqmfhwhodsnidkqmfsioj4enrdsbl0ifvotugknoog2jdsoyvfiofrwdt0ioeicaeubevffhscbwczqmnscsbevffssvvfvfgkowsftnwgmbcsbegvqdycyqqhocrzronzbocsckfeutagtkeqkznsywaeouqmiotvscfwzktlofinvtfcwfvkkfowvsfovuofinvtfseyzkvibybobsjoaseyruykvstvhkkfowvscsbweaonj0pbcoenrdsfxjbozkmwcoeftuiywbscczusgkfkhviqbctmobwnidcaewvfcsiooaboiseykbshzevjvstvkznsogwesctunzbdwbcaqycabefwzktlofinvtfcwfvkiqodvuofinvtkej4inwebobqpbecxj1utunoefzej4grwcariceisbfqnoymiqcjnojvnevsfigqzekgcuiovlkfowvsk5', |
|
67
|
|
|
], |
|
68
|
|
|
[ |
|
69
|
|
|
encode, |
|
70
|
|
|
[ |
|
71
|
|
|
"Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country", |
|
72
|
|
|
"data", |
|
73
|
|
|
], |
|
74
|
|
|
'gdyldscsdzcdijlthncxlvalnvuhbgmugdylvlnaktbp0udukbuwqidmgbtmaepovmmtuhgbhndxdqo1dbktdohoabk3auxamcsdbdabkt4ro1bkotqvqisgxfzmvlxbvfhibteuhndembualihnaxaqtmbhawdmdskamdmhstkapbdtmtzsdmryo1dxmtqaertradlhmpxud1hnbkwlmdedtmarwnqmkbvgcuhbnhktqtedurzgy4xdkaofdmgbhbgvcmdstagvaqtbjbbp0uduz0', |
|
75
|
|
|
], |
|
76
|
|
|
[ |
|
77
|
|
|
encode, |
|
78
|
|
|
[ |
|
79
|
|
|
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.", |
|
80
|
|
|
"goodmorming", |
|
81
|
|
|
], |
|
82
|
|
|
'jmeprghwvdmdjmgwoxcoawamhyfewauvpeborqgxfmhncpoxbfafbaamivrdmdqmdsjcnrawmdjmoefafbcgnttn', |
|
83
|
|
|
], |
|
84
|
|
|
[ |
|
85
|
|
|
encode, |
|
86
|
|
|
[ |
|
87
|
|
|
"One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment.", |
|
88
|
|
|
"iddqd", |
|
89
|
|
|
], |
|
90
|
|
|
'poflpllqunvjglknfhplviltbvrhfglptzlpwqslctcmhiltjfhm0uafdlylmexmqotepllfqdogeyijqdmuvhovx3lciphsklldoglsi1poeavilnnvlmcejibihcmqdejfsemzfieavehiqbseussmfjkinvmiylfjeycppvpqlss4ysqefvs4amlfqbmqqdsaifqc1ixkjfyemulvsdktetkisdpotujfijctqdunvbvecoim1iipfsrav1kldsqoitksflfilkbqzslvseifmhhdl0nplfmu', |
|
91
|
|
|
], |
|
92
|
|
|
[ |
|
93
|
|
|
encode, |
|
94
|
|
|
["The quick, brown fox jumps over a lazy dog.", "iddqd"], |
|
95
|
|
|
'vfgisqkrcppvmgrvgwnrvlshocoi0zamf0', |
|
96
|
|
|
], |
|
97
|
|
|
[ |
|
98
|
|
|
encode, |
|
99
|
|
|
[ |
|
100
|
|
|
"A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now. When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary", |
|
101
|
|
|
"9876543210", |
|
102
|
|
|
], |
|
103
|
|
|
'1ytiefxlxiqgqfijszgbto1mhkqpryqgryomtircs5hkonqftpximjqkzngqgq7khqistljimyrctqolmhzeoicnhkipzxnognzxctkfcf0songs0mtig1jhgffkznfdgbslrcfwmoqhihcktzcnrytqpozeoiezgyfog1qhegpsznh1mjrytpgru9mrmjqknjkhm3sytc2ssvs5ef0slxkcjhtpb3tpt0fejiznfwfwowmonogqhkqgrckgqfosbmowjmfwmoqhihhqgbonkhfmfdsnzs0mhkotmoctxih2ckih2sb3kfrcfp1yjimgommhkftospqkbszndqqfqgtziskgtzbmgvhqlcfwfkznbsjidwfqy1ygfsg1qhs0somorzznbmitxyzehkzejmhqcfirwdmxy2r6kfzsfwgkqynodz2su9s0spzigjg1jhzngkfqjcm3mtzitoolqktocfvoqdstxog0dfrcznckjshkhqs00nfgrim3hfrcs5osfwgqbmh2zo0gk7tos05mkfgsrytog1mjtzpocfjikhstbmhoy3sx', |
|
104
|
|
|
], |
|
105
|
|
|
[ |
|
106
|
|
|
encode, |
|
107
|
|
|
[ |
|
108
|
|
|
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure", |
|
109
|
|
|
"xyzqwerty", |
|
110
|
|
|
], |
|
111
|
|
|
'r1bglvmdxysmbhmamql1inzcurmrijlnkoabsdohkdbnkrzsl1pahojmsxdn4fzdsalcbhokmhnchozcodlb0hsajqfomfg1xzl1bdpnsmydzdrwbp0lbmgrkzmemdysh0kdwll1saagzdda0rmrzdajhokmliagykdxbaxysmlbxdliagydf4agagysdndytc1fsrxdlif0nt0ncnojszlelolqpoxdwkwddmbklmjfd3lbt01ok3smzdl3dxgb3duldqdb3lqkbglssxdn4fqdvrdqdb3lydin3dzjsbpombhspqinycps4fl3wssxdn4fxdbao10hurmxzsbp0ldytdpo3dx1zsdwmdnhabdxxyatysxswmbhlh4uoptbhthokoagxdzdmzpoxeinmp3ylpcl4fl3d3lbkdokdxmdlq1iabhoncholigb3duldqdb3lqkbglsbhoavrdqdb3lqsrwdbokpornmxbjtdvlmdh0dwlprwr2bfpzijajbmfoh0csbhpah0lcpb4fzkgolpsyftzdcmsxdn4fxq', |
|
112
|
|
|
], |
|
113
|
|
|
] |
|
114
|
|
|
|
|
115
|
|
|
DECODE_TESTS = [ |
|
116
|
|
|
[ |
|
117
|
|
|
decode, |
|
118
|
|
|
[ |
|
119
|
|
|
"gdyldscsdzcdijlthncxlvalnvuhbgmugdylvlnaktbp0udukbuwqidmgbtmaepovmmtuhgbhndxdqo1dbktdohoabk3auxamcsdbdabkt4ro1bkotqvqisgxfzmvlxbvfhibteuhndembualihnaxaqtmbhawdmdskamdmhstkapbdtmtzsdmryo1dxmtqaertradlhmpxud1hnbkwlmdedtmarwnqmkbvgcuhbnhktqtedurzgy4xdkaofdmgbhbgvcmdstagvaqtbjbbp0uduz0", |
|
120
|
|
|
"data", |
|
121
|
|
|
], |
|
122
|
|
|
'farfarawaybehindthewordmountainsfarfromthecountriesvokaliaandconsonantiatherelivetheblindtextsseparatedtheyliveinboxokmarksgroverightatxthecoastofthesemanticsalargelanguageoceanasmallrivernamedxdudenflowsbytheirplaceandsuppliesitwiththenecesxsaryregelialiaitisaparadisematiccountryz', |
|
123
|
|
|
], |
|
124
|
|
|
[ |
|
125
|
|
|
decode, |
|
126
|
|
|
[ |
|
127
|
|
|
"jmeprghwvdmdjmgwoxcoawamhyfewauvpeborqgxfmhncpoxbfafbaamivrdmdqmdsjcnrawmdjmoefafbcgnttn", |
|
128
|
|
|
"goodmorming", |
|
129
|
|
|
], |
|
130
|
|
|
'loremipsumdolorsitametconsectetueradipiscingelitaeneancomxmodoligulaegetdoloraeneanmassa', |
|
131
|
|
|
], |
|
132
|
|
|
[ |
|
133
|
|
|
decode, |
|
134
|
|
|
[ |
|
135
|
|
|
"poflpllqunvjglknfhplviltbvrhfglptzlpwqslctcmhiltjfhm0uafdlylmexmqotepllfqdogeyijqdmuvhovx3lciphsklldoglsi1poeavilnnvlmcejibihcmqdejfsemzfieavehiqbseussmfjkinvmiylfjeycppvpqlss4ysqefvs4amlfqbmqqdsaifqc1ixkjfyemulvsdktetkisdpotujfijctqdunvbvecoim1iipfsrav1kldsqoitksflfilkbqzslvseifmhhdl0nplfmu", |
|
136
|
|
|
"iddqd", |
|
137
|
|
|
], |
|
138
|
|
|
'onemorningwhengregorsamsawokefromtroubledxdreamshefoundhimselftransformedinhisbedintoahorxribleverminhelayonhisarmourlikebackandifheliftedhisheadalitxtlehecouldseehisbrownbellyslightlydomedanddividedbyarchesintostifxfsectionsthebedxdingwashardlyabletocoveritandsexemedreadytoslideoffanymoment', |
|
139
|
|
|
], |
|
140
|
|
|
[ |
|
141
|
|
|
decode, |
|
142
|
|
|
["vfikwgejntasbcnzmrpqzeshwnqb2oybe1", "nobody"], |
|
143
|
|
|
'thequickbrownfoxjumpsoveralazydogz', |
|
144
|
|
|
], |
|
145
|
|
|
[ |
|
146
|
|
|
decode, |
|
147
|
|
|
[ |
|
148
|
|
|
"1ytiefxlxiqgqfijszgbto1mhkqpryqgryomtircs5hkonqftpximjqkzngqgq7khqistljimyrctqolmhzeoicnhkipzxnognzxctkfcf0songs0mtig1jhgffkznfdgbslrcfwmoqhihcktzcnrytqpozeoiezgyfog1qhegpsznh1mjrytpgru9mrmjqknjkhm3sytc2ssvs5ef0slxkcjhtpb3tpt0fejiznfwfwowmonogqhkqgrckgqfosbmowjmfwmoqhihhqgbonkhfmfdsnzs0mhkotmoctxih2ckih2sb3kfrcfp1yjimgommhkftospqkbszndqqfqgtziskgtzbmgvhqlcfwfkznbsjidwfqy1ygfsg1qhs0somorzznbmitxyzehkzejmhqcfirwdmxy2r6kfzsfwgkqynodz2su9s0spzigjg1jhzngkfqjcm3mtzitoolqktocfvoqdstxog0dfrcznckjshkhqs00nfgrim3hfrcs5osfwgqbmh2zo0gk7tos05mkfgsrytog1mjtzpocfjikhstbmhoy3sx", |
|
149
|
|
|
"9876543210", |
|
150
|
|
|
], |
|
151
|
|
|
'awonderfulserenityhastakenposxsesxsionofmyentiresoullikethesesweetmorningsofspringwhichienjoywithmywholeheartiamaloneandfeelthecharmofexistenceinthisxspotwhichwascreatedfortheblisxsofsoulslikemineiamsohappymydearfriendsoabsorbedinthexexquisitesenseofmeretranquilexistencethatineglectmytalentsishouldbeincapableofdrawingasinglestrokeatthepresentmomentandyetifexelthatineverwasagreaterartistxthannowxwhenwhilethelovelyvalxleytexemswithvapouraroundmeandthemeridiansunstrikestheuppersurfaceoftheimpenetrablefoliageofmytrexesandbutafewstraygleamsxstealintotheinnersanctuary', |
|
152
|
|
|
], |
|
153
|
|
|
[ |
|
154
|
|
|
decode, |
|
155
|
|
|
[ |
|
156
|
|
|
"r1bglvmdxysmbhmamql1inzcurmrijlnkoabsdohkdbnkrzsl1pahojmsxdn4fzdsalcbhokmhnchozcodlb0hsajqfomfg1xzl1bdpnsmydzdrwbp0lbmgrkzmemdysh0kdwll1saagzdda0rmrzdajhokmliagykdxbaxysmlbxdliagydf4agagysdndytc1fsrxdlif0nt0ncnojszlelolqpoxdwkwddmbklmjfd3lbt01ok3smzdl3dxgb3duldqdb3lqkbglssxdn4fqdvrdqdb3lydin3dzjsbpombhspqinycps4fl3wssxdn4fxdbao10hurmxzsbp0ldytdpo3dx1zsdwmdnhabdxxyatysxswmbhlh4uoptbhthokoagxdzdmzpoxeinmp3ylpcl4fl3d3lbkdokdxmdlq1iabhoncholigb3duldqdb3lqkbglsbhoavrdqdb3lqsrwdbokpornmxbjtdvlmdh0dwlprwr2bfpzijajbmfoh0csbhpah0lcpb4fzkgolpsyftzdcmsxdn4fxq", |
|
157
|
|
|
"xyzqwerty", |
|
158
|
|
|
], |
|
159
|
|
|
'butimustexplaintoyouhowalxlthismistakenideaofdenouncingpleasureandpraisingpainwasbornandiwillgiveyouacompleteacxcountofthesystemandexpoundtheactualteachingsofthegreatexplorerofthetruththemasterbuilderofhumanhappinesxsnoxonerejectsdislikesoravoidspleasureitselfbecauseitispleasurebutbecausethosewhodonotknowhowtopursuepleasurerationalxlyencounterconsequencesthatareextremelypainfulnoragainisthereanyonewholovesorpursuesordesirestoxobtainpainofitselfbecauseitispainbutbecauseocxcasionallycircumstancesocxcurinwhichtoilandpaincanprocurehimsomegreatpleasurez', |
|
160
|
|
|
], |
|
161
|
|
|
[ |
|
162
|
|
|
decode, |
|
163
|
|
|
[ |
|
164
|
|
|
"hrflbtcztzdqijsaagxelbtsl1mabholhrflblvgkzbp0latkqm3sirnhbh0rdpolp0hmahbagxdxsg1ydkzrohoraxydm3dnctbdyrakzxmg1qkoalqsintdfmkbl3ybfhiabryagwdnbmdliagd3ysh0bgdprnbtkynrmh0rkypbzd0hlnrnufg1xd0hsyrer3kdlhmpeptqagqkclnrdwh0k32lsmkqokcygbgakzszdwlendtxdxkyofrnhbgbkocnbtbrkoysbajbbp0latzq", |
|
165
|
|
|
"xyzqwerty", |
|
166
|
|
|
], |
|
167
|
|
|
'farfarawaybehindthewordmountainsfarfromthecountriesvokaliaandconsonantiatherelivetheblindtextsseparatedtheyliveinboxokmarksgroverightatxthecoastofthesemanticsalargelanguageoceanasmallrivernamedxdudenflowsbytheirplaceandsuppliesitwiththenecesxsaryregelialiaitisaparadisematiccountryz', |
|
168
|
|
|
], |
|
169
|
|
|
[ |
|
170
|
|
|
decode, |
|
171
|
|
|
[ |
|
172
|
|
|
"irqfnjqtyicpirstnogshqiumtfdqhozfq2gjomoiomhfkno1gkhbmiulyiscpmjcym0fhhqcpirs0hkg1ingyyg", |
|
173
|
|
|
"9876543210", |
|
174
|
|
|
], |
|
175
|
|
|
'loremipsumdolorsitametconsectetueradipiscingelitaeneancomxmodoligulaegetdoloraeneanmassa', |
|
176
|
|
|
], |
|
177
|
|
|
[ |
|
178
|
|
|
decode, |
|
179
|
|
|
[ |
|
180
|
|
|
"bogknsacdcvicocufhnswokui3esfgsnlusntdkfn1nuiokuifebrdyggqzktlusnotenskgagycewofagbrbneyx4wcfthscsqgycfknaboicwoujdstjeqfoniqooycgifqfl0goicveioynqfr00tfifedsmbzkfiewntasodfkpbtkchfvpbybkgynoyagwhogydanxjifwebrezwfc0etfewfbotuifofn1agdc3ivenwbmanftfsneyscsfwnoouczgkgoscnybvezqfogbeiboakdkgbr", |
|
181
|
|
|
"nobody", |
|
182
|
|
|
], |
|
183
|
|
|
'onemorningwhengregorsamsawokefromtroubledxdreamshefoundhimselftransformedinhisbedintoahorxribleverminhelayonhisarmourlikebackandifheliftedhisheadalitxtlehecouldseehisbrownbellyslightlydomedanddividedbyarchesintostifxfsectionsthebedxdingwashardlyabletocoveritandsexemedreadytoslideoffanymoment', |
|
184
|
|
|
], |
|
185
|
|
|
[ |
|
186
|
|
|
decode, |
|
187
|
|
|
["vfgisqkrcppvmgrvgwnrvlshocoi0zamf0", "iddqd"], |
|
188
|
|
|
'thequickbrownfoxjumpsoveralazydogz', |
|
189
|
|
|
], |
|
190
|
|
|
[ |
|
191
|
|
|
decode, |
|
192
|
|
|
[ |
|
193
|
|
|
"etgarbievkwnepfgszjntubjfajrtswntsxggaiag1faxoeptgvkqmpbsjnwnw2pawrdgegfnyiawhighnspmfqgfata2soxlg2sjgpcpneoxococjgafbbgnfcpsjfejniriafwgxwaaefrasqgtswhazspmfpsntemfbwaibdisjfcqmtstgnxdthvqmpbrgafofgvgjejh2g1rbeoeirfbgtgbctgdebrgfsjfwfwkxgxoxnwfawniarcepwobakxmqfwgxwaaeawjnxoafmhfevozscjfautgxjgvkbkfraeejbcpciamietgfonxghnpctuidpbjzsjpwepwnasrdrcasbag0awfqfwcpsjjzgfcwpetetnoifbwaoeowgxussjbaagxsspfaspmqawpnjmwch1tcqvpczsfwcrtxoxlsejdtoeidsbmrfbbgsjcrpegmofhysbtuigpbtupnwkwpgwwdnbefiasjfrrlfaawoeckfnmjofrniag1wofwnwbabkvubnp2tuoe4npccotstufbqmasazpngfafgwbaavtbg2", |
|
194
|
|
|
"goodmorming", |
|
195
|
|
|
], |
|
196
|
|
|
'awonderfulserenityhastakenposxsesxsionofmyentiresoullikethesesweetmorningsofspringwhichienjoywithmywholeheartiamaloneandfeelthecharmofexistenceinthisxspotwhichwascreatedfortheblisxsofsoulslikemineiamsohappymydearfriendsoabsorbedinthexexquisitesenseofmeretranquilexistencethatineglectmytalentsishouldbeincapableofdrawingasinglestrokeatthepresentmomentandyetifexelthatineverwasagreaterartistxthannowxwhenwhilethelovelyvalxleytexemswithvapouraroundmeandthemeridiansunstrikestheuppersurfaceoftheimpenetrablefoliageofmytrexesandbutafewstraygleamsxstealintotheinnersanctuary', |
|
197
|
|
|
], |
|
198
|
|
|
[ |
|
199
|
|
|
decode, |
|
200
|
|
|
[ |
|
201
|
|
|
"tvbhnsuak3qmbguhl1nvinscqrndijzsgvbtqkohadbmlftqnvpthojmqdgzvsdtltlwbgvgmhmchoscvalvmtltjvfomfo1d3nvtepnqmdbdtewbp0ubnhdktrzuaaqtmadwqnvlthndtebstnddttjhomzlihnakxdtbk3qmlvdxlihndbsvhnhnaqgzbdvdvhrfdxlin0sguncmojqturumqvpodxckdeaubfrmjfaxlvbsvoarqmdtuvxdhbxarlcdetvubkbhwmqdgzvsdc0hcdetvudbinxaujlbponbhqpvinucpqvsuvcqqdgzvsdxtbovmtqrr4tqbp0ubdwdpoxanxtqeduagtbtxdk3duaqdq2lbglhrnopsdmghogvhndxdtl0pocxinmpxbvmwlvsuvaxlvadvgxduaqvvibthomcholihbxarlcdetvubkbhwmbgot0hcdetvubqewetvgpodmr4bjwdsnuatmedvmewtwvfpuijtjbnfotmclbgpttmlwpbvstkgovmqafsdtcnqdgzvsa3", |
|
202
|
|
|
"data", |
|
203
|
|
|
], |
|
204
|
|
|
'butimustexplaintoyouhowalxlthismistakenideaofdenouncingpleasureandpraisingpainwasbornandiwillgiveyouacompleteacxcountofthesystemandexpoundtheactualteachingsofthegreatexplorerofthetruththemasterbuilderofhumanhappinesxsnoxonerejectsdislikesoravoidspleasureitselfbecauseitispleasurebutbecausethosewhodonotknowhowtopursuepleasurerationalxlyencounterconsequencesthatareextremelypainfulnoragainisthereanyonewholovesorpursuesordesirestoxobtainpainofitselfbecauseitispainbutbecauseocxcasionallycircumstancesocxcurinwhichtoilandpaincanprocurehimsomegreatpleasurez', |
|
205
|
|
|
], |
|
206
|
|
|
] |
|
207
|
|
|
|
|
208
|
|
|
def test_Basics(self): |
|
209
|
|
|
for i in self.BASIC_TESTS: |
|
210
|
|
|
assert i[0](*i[1]) == i[2] |
|
211
|
|
|
|
|
212
|
|
|
def test_Encode(self): |
|
213
|
|
|
for i in self.ENCODE_TESTS: |
|
214
|
|
|
assert i[0](*i[1]) == i[2] |
|
215
|
|
|
|
|
216
|
|
|
def test_Decode(self): |
|
217
|
|
|
for i in self.DECODE_TESTS: |
|
218
|
|
|
assert i[0](*i[1]) == i[2] |
|
219
|
|
|
|
|
220
|
|
|
def test_Random(self): |
|
221
|
|
|
for _ in range(5): |
|
222
|
|
|
length = random.randint(10, 18) * 2 |
|
223
|
|
|
list_message = list(string.ascii_lowercase + string.digits) |
|
224
|
|
|
random.shuffle(list_message) |
|
225
|
|
|
message = "".join(list_message[:length]) |
|
226
|
|
|
key = "".join(random.choice(string.ascii_lowercase) for __ in range(6)) |
|
227
|
|
|
assert decode(encode(message, key), key) == message |
|
228
|
|
|
|
|
229
|
|
|
|
|
230
|
|
|
if __name__ == "__main__": # pragma: no cover |
|
231
|
|
|
unittest.main() |
|
232
|
|
|
|