Module: ActiveCrypto::KeyHolder

Included in:
AssociationKeyHolder
Defined in:
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.



127
128
129
# File 'lib/active_crypto.rb', line 127

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

#session_keyObject

Returns the session_key



148
149
150
# File 'lib/active_crypto.rb', line 148

def session_key
  @session_key
end

#set_encoded_key(enc) ⇒ Object

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



134
135
136
# File 'lib/active_crypto.rb', line 134

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.



140
141
142
143
# File 'lib/active_crypto.rb', line 140

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