Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # unshuffle.py
- import random
- the_key = 543210123
- msg = ['Viygae eIebe\nbZtttyef\nl\'aoYy uo)a b,blde gge8h lasyy ec.O e httetlp e\nosyssahny ieioleedg t-uaape\nteeclehntiobeed epcnohnshbt ss ch\' nsh i. Du iteopa :,halgegeu \nupieanmrPrl.p?Jepr,mfqttueiYf l\n o totoh otpenatli tAn.sNo\nui eWoml gdxnb u! e.4rnEgd!ear\npam eEnoelnspiitnA eTd lo uib fftn t hsu\nn.\nljTntiellksassas\nIenttaduryi rracfrokeseiodbhpdxa ePtAnraebte-esctoethodo.a ht\nc bws tvnneel mopbiaasd orn or t litee\nAtvi-imrL i7 nWehs .av i2 Cemam m6lsegcsix-td tnbx liefee eCt\n ie xiai ean\' xu tcNntjlcyiytse\nyh Zsae\'ts ehrsv \nty ,ll l\n o\n tn"o hs emtearhcm gTthecaf.tRelIoribaOt r-auies.otne1iwMm;edpdXe \n.nansoE ru(aaeUiaioc\nuboe lh. hDkB rttou*iSns ebotbnH\neTrnHn rnUu iaqFmSargystheh\n s smvp,oelN ollfusytbtzo ahpatiycfSt*K\nnea\nnpesheoyseumQ.irtoooroshG\nwt p bl-rarititisll.yt t oR\nr pleeatl ispstwlEfteutx\nooi eosSFEta ab te e \neBpa neo hT l.be h elreN aitgt\n 9rd sihunatawhii screx.u orcpraIt c0idcFll\nh *.itreOoedmitzatH tvti paN5 gfr\'!mkive idwH3.unorlttd nas '][0]
- def decrypt(message, key):
- random.seed(key)
- L = list(range(len(message)))
- random.shuffle(L)
- return "".join(message[i] for i, x in sorted(enumerate(L), key=lambda x: x[1]))
- def encrypt(message, key):
- random.seed(key)
- L = range(len(message))
- random.shuffle(L)
- sss = "".join([message[x] for x in L])
- return sss
- '''
- code = encrypt(msg, the_key)
- print [code]
- '''
- decoded = decrypt(msg, the_key)
- print decoded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement