Skip to content

Instantly share code, notes, and snippets.

@ahmad19
Created June 6, 2020 17:10
Show Gist options
  • Save ahmad19/176ed577a64e0d9b962cd7f7ff0c6e8f to your computer and use it in GitHub Desktop.
Save ahmad19/176ed577a64e0d9b962cd7f7ff0c6e8f to your computer and use it in GitHub Desktop.
def encrypt_alt(message,final_shift)
character_set = ("a".."z").to_a << " "
split_message = message.split("")
offset_array = split_message.map.with_index do |char, index|
f_index = (index % 4) + 1
new_index = final_shift[f_index - 1]
char_index = character_set.find_index(char)
new_char_index = (char_index + new_index) % 27
character_set[new_char_index]
end.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment