Advertisement
Python253

kryptos_c2_decoder

Mar 1st, 2024
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: kryptos_c2_decoder.py
  3. # Author: Jeoi Reqi
  4. # Decoder for The Kryptos Ciphers C2
  5.  
  6. # Function for the vigenere cryptography
  7. def vigenere_decoder(ciphertext, key, alphabet):
  8.     plaintext = ''
  9.     key_index = 0
  10.     for c in ciphertext:
  11.         if c not in alphabet:
  12.             plaintext += c
  13.             continue
  14.         shift = alphabet.index(key[key_index])
  15.         ciphertext_index = alphabet.index(c)
  16.         plaintext_index = (ciphertext_index - shift) % len(alphabet)
  17.         plaintext += alphabet[plaintext_index]
  18.         key_index = (key_index + 1) % len(key)
  19.     return plaintext
  20.  
  21. ciphertext = "VFPJUDEEHZWETZYVGWHKKQETGFQJNCEGGWHKKDQMCPFQZDQMMIAGPFXHQRLGTIMVMZJANQLVKQEDAGDVFRPJUNGEUNAQZGZLECGYUXUEENJTBJLBQCRTBJDFHRRYIZETKZEMVDUFKSJHKFWHKUWQLSZFTIHHDDDUVH?DWKBFUFPWNTDFIYCUQZEREEVLDKFEZMOQQJLTTUGSYQPFEUNLAVIDXFLGGTEZ?FKZBSFDQVGOGIPUFXHHDRKFFHQNTGPUAECNUVPDJMQCLQUMUNEDFQELZZVRRGKFFVOEEXBDMVPNFQXEZLGREDNQFMPNZGLFLPMRJQYALMGNUVPDXVKPDQUMEBEDMHDAFMJGZNUPLGEWJLLAETG"
  22. key = "ABSCISSA"
  23. alphabet = "KRYPTOSABCDEFGHIJLMNQUVWXZ"
  24.  
  25. plaintext = vigenere_decoder(ciphertext, key, alphabet)
  26.  
  27. # Print the decrypted plaintext
  28. print(plaintext)
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement