Skip to content

Instantly share code, notes, and snippets.

@AaronRandall
Created March 28, 2016 10:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AaronRandall/41bbf4032ad6166cdbaa to your computer and use it in GitHub Desktop.
Save AaronRandall/41bbf4032ad6166cdbaa to your computer and use it in GitHub Desktop.
ciphertexts = [
"VGYURYPEDFNCEPGEWELLPVNWRDCNFGMGXQEPPRG-CBFIGLEMG",
"EQ’PMEIGQNVBAGBTFEGMSYNRKMNWEPBLWBYPSNWMQNFBDWEQVYNR-CBFIGLEMG"
]
names = [
"RYANNORTH",
"BUBBLEGUM",
"MARCELINE",
"RAINICORN"
]
signature = "CBFIGLEMG"
known_keys = signature.chars
all_keys = ("A".."Z").to_a
unknown_keys = (all_keys - known_keys)
names.each do |name|
puts "Name: #{name}"
ciphertexts.each do |ciphertext|
ciphertext_before = ciphertext
ciphertext_after = ciphertext.tr(signature, name)
ciphertext_known_keys = ciphertext.tr(unknown_keys.join, "_").tr(signature, name)
puts "Ciphertext before: #{ciphertext_before}"
puts "Ciphertext after: #{ciphertext_after}"
puts "Ciphertext known keys: #{ciphertext_known_keys}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment