Class: ActiveRecord::Coders::Encryptors::AES
- Inherits:
-
Object
- Object
- ActiveRecord::Coders::Encryptors::AES
- Defined in:
- lib/active_record/coders/encryptors/aes.rb
Instance Attribute Summary collapse
-
#cipher ⇒ Object
readonly
Returns the value of attribute cipher.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #dump(data) ⇒ Object
-
#initialize(password, size = 256, options = {}) ⇒ AES
constructor
A new instance of AES.
- #load(data) ⇒ Object
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, = {}) @cipher = ::Gibberish::AES.new(password, size) = { binary: true }.merge() end |
Instance Attribute Details
#cipher ⇒ Object (readonly)
Returns the value of attribute cipher.
3 4 5 |
# File 'lib/active_record/coders/encryptors/aes.rb', line 3 def cipher @cipher end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/active_record/coders/encryptors/aes.rb', line 3 def 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, ) 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, ) rescue nil end |