Advertisement
ghost423543

Monoalphabetic_substitution-Caesar

Nov 4th, 2020
2,960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import string
  2.  
  3. cipher_text=b"""tm bcsv qolfp
  4. f'dmvd xuhm exl tgak
  5. hlrkiv sydg hxm
  6. qiswzzwf qrf oqdueqe
  7. dpae resd wndo
  8. liva bu vgtokx sjzk
  9. hmb rqch fqwbg
  10. fmmft seront sntsdr pmsecq""".replace(b'\'',b' ')
  11.  
  12. plain_text = b''
  13. flag_first,flag_last = b'',b''
  14. alphabet = string.printable[10:-64].encode()
  15. shift = 1
  16. for ci in cipher_text.split(b'\n'):
  17.     tmp = ci.split(b' ')
  18.     line_plain_text = b''
  19.     for word in tmp:
  20.         line_plain_text+=bytes([ alphabet[(alphabet.index(c)+shift)%26] if c in alphabet else c for c in word])
  21.         shift+=1
  22.         line_plain_text+=b' '
  23.     flag_first+=bytes([line_plain_text[0]])
  24.     flag_last+=bytes([line_plain_text[-2]])
  25.     plain_text+=line_plain_text+b'\n'
  26. print(plain_text.decode())
  27. print("[+]FLAG:",(flag_first+flag_last).decode())
  28. ## ujqcsddessxsffes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement