Skip to content

Instantly share code, notes, and snippets.

@santouras
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santouras/3ad609038e4dcac9c811 to your computer and use it in GitHub Desktop.
Save santouras/3ad609038e4dcac9c811 to your computer and use it in GitHub Desktop.
atbash
class Atbash
ARR = ('a'..'z').to_a
def self.encode str
str.
downcase.
each_char.map { |c| cipher(c) }.join.
scan(/.{1,5}/).join(" ")
end
private
def self.cipher char
return char if ('0'..'9').include? char
return ARR.reverse[ARR.index(char)] if ARR.include?(char)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment