Class: Hanvon::Crypto
- Inherits:
-
Object
- Object
- Hanvon::Crypto
- Defined in:
- lib/hanvon/crypto.rb
Defined Under Namespace
Classes: InvalidPasswordException
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
- #convert(message, offset = 0) ⇒ Object (also: #encrypt, #decrypt)
-
#initialize(password) ⇒ Crypto
constructor
A new instance of Crypto.
Constructor Details
#initialize(password) ⇒ Crypto
8 9 10 |
# File 'lib/hanvon/crypto.rb', line 8 def initialize(password) self.password = password end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/hanvon/crypto.rb', line 6 def password @password end |
Instance Method Details
#convert(message, offset = 0) ⇒ Object Also known as: encrypt, decrypt
12 13 14 15 16 |
# File 'lib/hanvon/crypto.rb', line 12 def convert(, offset = 0) .each_char.each_with_index.collect do |char, pos| convert_char(char, pos + offset) end.pack('C*') end |