Class: ActiveRecord::Coders::Encryptors::AES

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/coders/encryptors/aes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(password, size = 256, options = {}) ⇒ AES

Returns a new instance of AES.



5
6
7
8
# File 'lib/active_record/coders/encryptors/aes.rb', line 5

def initialize(password, size = 256, options = {})
  @cipher = ::Gibberish::AES.new(password, size)
  @options = { binary: true }.merge(options)
end

Instance Attribute Details

#cipherObject (readonly)

Returns the value of attribute cipher.



3
4
5
# File 'lib/active_record/coders/encryptors/aes.rb', line 3

def cipher
  @cipher
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/active_record/coders/encryptors/aes.rb', line 3

def options
  @options
end

Instance Method Details

#dump(data) ⇒ Object



10
11
12
13
14
# File 'lib/active_record/coders/encryptors/aes.rb', line 10

def dump(data)
  cipher.encrypt(data, options)
rescue
  String.new
end

#load(data) ⇒ Object



16
17
18
19
20
# File 'lib/active_record/coders/encryptors/aes.rb', line 16

def load(data)
  cipher.decrypt(data, options)
rescue
  nil
end