Module: ParamCryptable

Extended by:
ActiveSupport::Concern
Defined in:
lib/param_cryptable.rb,
lib/param_cryptable/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.encrypt(text) ⇒ String

Encrypt any value for use by crypt_params

Parameters:

  • text (Object)

    The text to encrypt. This method calls ‘.to_s` on it.

Returns:

  • (String)

    The encrypted representation



18
19
20
21
22
23
24
# File 'lib/param_cryptable.rb', line 18

def self.encrypt(text)
  cipher = OpenSSL::Cipher.new('blowfish').encrypt
  cipher.key = Rails.application.credentials.param_cryptable_key

  s = cipher.update(text.to_s) + cipher.final
  s.unpack1('H*')
end

Instance Method Details

#encrypt(text) ⇒ String

Encrypt any value for use by crypt_params

Parameters:

  • text (Object)

    The text to encrypt. This method calls ‘.to_s` on it.

Returns:

  • (String)

    The encrypted representation



52
53
54
# File 'lib/param_cryptable.rb', line 52

def encrypt(text)
  ParamCryptable.encrypt(text)
end