Class Index [+]

Quicksearch

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

Public Instance Methods

sage_decrypt(ciphertext, key) click to toggle source
    # File lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb, line 10
10:           def sage_decrypt(ciphertext, key)
11:             sage_encrypt_xor(ActiveSupport::Base64.decode64(ciphertext), key)
12:           end
sage_encrypt(plaintext, key) click to toggle source
   # File lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb, line 6
6:           def sage_encrypt(plaintext, key)
7:             ActiveSupport::Base64.encode64s(sage_encrypt_xor(plaintext, key))
8:           end
sage_encrypt_salt(min, max) click to toggle source
    # File lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb, line 14
14:           def sage_encrypt_salt(min, max)
15:             length = rand(max - min + 1) + min
16:             SecureRandom.base64(length + 4)[0, length]
17:           end

Private Instance Methods

sage_encrypt_xor(data, key) click to toggle source
    # File lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb, line 21
21:           def sage_encrypt_xor(data, key)
22:             raise 'No key provided' if key.blank?
23:             
24:             key *= (data.length.to_f / key.length.to_f).ceil
25:             key = key[0, data.length]
26: 
27:             data.bytes.zip(key.bytes).map { |b1, b2| (b1 ^ b2).chr }.join
28:           end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.