Class: Hanvon::Crypto

Inherits:
Object
  • Object
show all
Defined in:
lib/hanvon/crypto.rb

Defined Under Namespace

Classes: InvalidPasswordException

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#passwordObject

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(message, offset = 0)
  message.each_char.each_with_index.collect do |char, pos|
    convert_char(char, pos + offset)
  end.pack('C*')
end