Class: Encrubto::RotN::Encryptor
- Inherits:
-
Object
- Object
- Encrubto::RotN::Encryptor
- Defined in:
- lib/encrubto/rotn/encryptor.rb
Constant Summary collapse
- ORIGINAL =
'abcdefghijklmnopqrstuvwxyz'
Instance Method Summary collapse
Instance Method Details
#decrypt(encrypted, offset) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/encrubto/rotn/encryptor.rb', line 15 def decrypt(encrypted, offset) if encrypted.is_a?(String) && offset.is_a?(Integer) rotn = shift(offset % 26) encrypted.tr("#{ rotn }#{ rotn.to_s.upcase }", "#{ ORIGINAL }#{ ORIGINAL.upcase }") else raise 'First param must be String, second param must be Integer!' end end |
#encrypt(str, offset) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/encrubto/rotn/encryptor.rb', line 6 def encrypt(str, offset) if str.is_a?(String) && offset.is_a?(Integer) rotn = shift(offset % 26) str.tr("#{ ORIGINAL }#{ ORIGINAL.upcase }", "#{ rotn }#{ rotn.to_s.upcase }") else raise 'First param must be String, second param must be Integer!' end end |