Module: ActiveMerchant::Billing::Integrations::SagePayForm::Encryption

Included in:
Helper, Notification
Defined in:
lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb

Instance Method Summary collapse

Instance Method Details

#sage_decrypt(ciphertext, key) ⇒ Object



10
11
12
# File 'lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb', line 10

def sage_decrypt(ciphertext, key)
  sage_encrypt_xor(ActiveSupport::Base64.decode64(ciphertext), key)
end

#sage_encrypt(plaintext, key) ⇒ Object



6
7
8
# File 'lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb', line 6

def sage_encrypt(plaintext, key)
  ActiveSupport::Base64.encode64s(sage_encrypt_xor(plaintext, key))
end

#sage_encrypt_salt(min, max) ⇒ Object



14
15
16
17
# File 'lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb', line 14

def sage_encrypt_salt(min, max)
  length = rand(max - min + 1) + min
  SecureRandom.base64(length + 4)[0, length]
end