class ActiveEncryption::EncryptionSetting::Key
The ActiveEncryption::EncryptionSetting::Key
class wraps around ActiveSupport::KeyGenerator
Constants
- DEFAULT_SALT
Attributes
iterations[R]
salt[R]
Public Class Methods
new(secret, salt: nil, cipher: nil, iterations: nil)
click to toggle source
# File lib/active_encryption/encryption_setting/key.rb, line 15 def initialize(secret, salt: nil, cipher: nil, iterations: nil) salt ||= DEFAULT_SALT @salt = salt @cipher = cipher @iterations = iterations @generator = ActiveSupport::KeyGenerator.new( secret, iterations: iterations ) end
Public Instance Methods
cipher()
click to toggle source
# File lib/active_encryption/encryption_setting/key.rb, line 30 def cipher @cipher ||= ActiveSupport::MessageEncryptor.default_cipher end
length()
click to toggle source
# File lib/active_encryption/encryption_setting/key.rb, line 34 def length ActiveSupport::MessageEncryptor.key_len(cipher) end
value()
click to toggle source
# File lib/active_encryption/encryption_setting/key.rb, line 26 def value @generator.generate_key(salt, length) end