Class: SpamProtect::Encryption::SecretKey

Inherits:
Object
  • Object
show all
Defined in:
lib/spam_protect/encryption/secret_key.rb

Class Method Summary collapse

Class Method Details

.relevant_key!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/spam_protect/encryption/secret_key.rb', line 7

def relevant_key!
  result = from_configuration || from_rails

  unless result.present?
    raise Errors::NoSecretKey
  end

  unless defined?(ActiveSupport::KeyGenerator) && defined?(ActiveSupport::MessageEncryptor)
    raise Errors::EncryptionUnavailable
  end

  key_len = ActiveSupport::MessageEncryptor.key_len

  ActiveSupport::KeyGenerator.new(result).generate_key("spam_protect", key_len)
end