Advertisement
here2share

# unshuffle.py

Jun 20th, 2021
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. # unshuffle.py
  2.  
  3. import random
  4.  
  5. the_key = 543210123
  6.  
  7. 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]
  8.  
  9. def decrypt(message, key):
  10.     random.seed(key)
  11.     L = list(range(len(message)))
  12.     random.shuffle(L)
  13.     return "".join(message[i] for i, x in sorted(enumerate(L), key=lambda x: x[1]))
  14.    
  15. def encrypt(message, key):
  16.     random.seed(key)
  17.     L = range(len(message))
  18.     random.shuffle(L)
  19.     sss = "".join([message[x] for x in L])
  20.     return sss
  21.  
  22. '''
  23. code = encrypt(msg, the_key)
  24. print [code]
  25. '''
  26.  
  27. decoded = decrypt(msg, the_key)
  28. print decoded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement