-
-
Save AaronRandall/34ace41bcadf8fe2ca2bb2e22816dcca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ciphertexts = [ | |
"VGYURYPEDFNCEPGEWELLPVNWRDCNFGMGXQEPPRG-CBFIGLEMG", | |
"EQ’PMEIGQNVBAGBTFEGMSYNRKMNWEPBLWBYPSNWMQNFBDWEQVYNR-CBFIGLEMG" | |
] | |
cipher_keys = "CBFIGLEMGQPRXWYNVDUATSK" | |
key_mappings = "MARCELINETSUXWYOHPGVFDK" | |
known_keys = cipher_keys.chars | |
all_keys = ("A".."Z").to_a | |
unknown_keys = (all_keys - known_keys) | |
ciphertexts.each do |ciphertext| | |
ciphertext_before = ciphertext | |
ciphertext_after = ciphertext.tr(cipher_keys, key_mappings) | |
ciphertext_known_keys = ciphertext.tr(unknown_keys.join, "_").tr(cipher_keys, key_mappings) | |
puts "Ciphertext before: #{ciphertext_before}" | |
puts "Ciphertext after: #{ciphertext_after}" | |
puts "Ciphertext known keys: #{ciphertext_known_keys}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment