Class: Voynich::ActiveRecord::DataKey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/voynich/active_record/models/data_key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#plaintextObject



22
23
24
25
26
27
28
29
30
# File 'lib/voynich/active_record/models/data_key.rb', line 22

def plaintext
  return @plaintext unless @plaintext.nil?
  if ciphertext.nil?
    generate_data_key
  else
    decrypt_data_key
  end
  @plaintext
end

Instance Method Details

#reencrypt!Object



16
17
18
19
20
# File 'lib/voynich/active_record/models/data_key.rb', line 16

def reencrypt!
  result = client.reencrypt(ciphertext)
  self.ciphertext = result.ciphertext
  save!
end