Class: ProviderKit::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/provider_kit/encryptor.rb

Overview

Wrapper around ActiveSupport::MessageEncryptor with a shared credential key

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sharedObject



17
18
19
# File 'lib/provider_kit/encryptor.rb', line 17

def self.shared
  @shared ||= new
end

Instance Method Details

#decrypt(encrypted_value, purpose: :provider) ⇒ Object



7
8
9
10
11
# File 'lib/provider_kit/encryptor.rb', line 7

def decrypt(encrypted_value, purpose: :provider)
  crypt.decrypt_and_verify(encrypted_value, purpose:)
rescue ActiveSupport::MessageVerifier::InvalidSignature
  nil
end

#encrypt(raw_value, purpose: :provider) ⇒ Object



13
14
15
# File 'lib/provider_kit/encryptor.rb', line 13

def encrypt(raw_value, purpose: :provider)
  crypt.encrypt_and_sign(raw_value, purpose:)
end