Module: ActiveCrypto::KeyHolder

Included in:
AssociationKeyHolder
Defined in:
lib/gems/ezcrypto-0.7/lib/active_crypto.rb

Overview

This module handles all standard key management features.

Instance Method Summary collapse

Instance Method Details

#enter_password(password, salt = "onetwothree") ⇒ Object

Creates a key for object based on given password and an optional salt.



117
118
119
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 117

def enter_password(password,salt="onetwothree")
  set_session_key(EzCrypto::Key.with_password(password, salt))
end

#session_keyObject

Returns the session_key



138
139
140
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 138

def session_key
  @session_key
end

#set_encoded_key(enc) ⇒ Object

Decodes the Base64 encoded key and uses it as it’s session key



124
125
126
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 124

def set_encoded_key(enc)
  set_session_key(EzCrypto::Key.decode(enc))
end

#set_session_key(key) ⇒ Object

Sets a session key for the object. This should be a EzCrypto::Key instance.



130
131
132
133
# File 'lib/gems/ezcrypto-0.7/lib/active_crypto.rb', line 130

def set_session_key(key)    
  @session_key=key
  self.decrypt_attributes if self.class.include? Encrypted
end