Skip to content

Instantly share code, notes, and snippets.

@jblakeman
Last active March 16, 2016 01:20
Show Gist options
  • Save jblakeman/287d248ace57f6e3aad6 to your computer and use it in GitHub Desktop.
Save jblakeman/287d248ace57f6e3aad6 to your computer and use it in GitHub Desktop.
Vignere Cipher Encryption
def vignere(message, keyword)
min_byte = 97
max_index = 26
cipher = ""
message.downcase.split("").each_with_index do |char, i|
cipher_i = (char.ord - min_byte) + (keyword[i].ord - min_byte)
cipher_i -= max_index if cipher_i > max_index
cipher += (cipher_i + min_byte).chr
end
cipher
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment