Skip to content

Instantly share code, notes, and snippets.

@novohispano
Created September 14, 2013 18:06
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 novohispano/6564183 to your computer and use it in GitHub Desktop.
Save novohispano/6564183 to your computer and use it in GitHub Desktop.
class Encryptor
def cypher(letter, rotation)
(letter.ord + rotation).chr
end
def encrypt(message, rotation)
letters = message.split("")
letters.collect { |letter| cypher(letter, rotation) }.join
end
def decrypt(message, rotation)
letters = message.split("")
letters.collect { |letter| cypher(letter, -rotation) }.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment