Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: kryptos_c2_decoder.py
- # Author: Jeoi Reqi
- # Decoder for The Kryptos Ciphers C2
- # Function for the vigenere cryptography
- def vigenere_decoder(ciphertext, key, alphabet):
- plaintext = ''
- key_index = 0
- for c in ciphertext:
- if c not in alphabet:
- plaintext += c
- continue
- shift = alphabet.index(key[key_index])
- ciphertext_index = alphabet.index(c)
- plaintext_index = (ciphertext_index - shift) % len(alphabet)
- plaintext += alphabet[plaintext_index]
- key_index = (key_index + 1) % len(key)
- return plaintext
- ciphertext = "VFPJUDEEHZWETZYVGWHKKQETGFQJNCEGGWHKKDQMCPFQZDQMMIAGPFXHQRLGTIMVMZJANQLVKQEDAGDVFRPJUNGEUNAQZGZLECGYUXUEENJTBJLBQCRTBJDFHRRYIZETKZEMVDUFKSJHKFWHKUWQLSZFTIHHDDDUVH?DWKBFUFPWNTDFIYCUQZEREEVLDKFEZMOQQJLTTUGSYQPFEUNLAVIDXFLGGTEZ?FKZBSFDQVGOGIPUFXHHDRKFFHQNTGPUAECNUVPDJMQCLQUMUNEDFQELZZVRRGKFFVOEEXBDMVPNFQXEZLGREDNQFMPNZGLFLPMRJQYALMGNUVPDXVKPDQUMEBEDMHDAFMJGZNUPLGEWJLLAETG"
- key = "ABSCISSA"
- alphabet = "KRYPTOSABCDEFGHIJLMNQUVWXZ"
- plaintext = vigenere_decoder(ciphertext, key, alphabet)
- # Print the decrypted plaintext
- print(plaintext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement