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(options = {}) ⇒ AES
constructor
A new instance of AES.
- #load(data) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ AES
Returns a new instance of AES.
5 6 7 8 9 10 11 12 |
# File 'lib/active_record/coders/encryptors/aes.rb', line 5 def initialize( = {}) password = [:password] key_length = [:key_length] || 256 binary = !![:binary] @cipher = ::Gibberish::AES.new(password, key_length) = { binary: binary } 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
14 15 16 17 18 |
# File 'lib/active_record/coders/encryptors/aes.rb', line 14 def dump(data) cipher.encrypt(data, ) rescue String.new end |
#load(data) ⇒ Object
20 21 22 23 24 |
# File 'lib/active_record/coders/encryptors/aes.rb', line 20 def load(data) cipher.decrypt(data, ) rescue nil end |