Module: Util

Defined in:
lib/flutterwave_sdk/flutterwave_modules/util.rb

Class Method Summary collapse

Class Method Details

.encrypt(key, data) ⇒ Object

method for encryption algorithm



17
18
19
20
21
22
23
24
25
# File 'lib/flutterwave_sdk/flutterwave_modules/util.rb', line 17

def self.encrypt(key, data)
  cipher = OpenSSL::Cipher.new("des-ede3")
  cipher.encrypt # Call this before setting key
  cipher.key = key
  data = data.to_json
  ciphertext = cipher.update(data)
  ciphertext << cipher.final
  return Base64.encode64(ciphertext)
end

.transaction_reference_generatorObject

method to generate merchants transaction reference



11
12
13
14
# File 'lib/flutterwave_sdk/flutterwave_modules/util.rb', line 11

def self.transaction_reference_generator
  transaction_ref = "MC-" + SecureRandom.hex
  return transaction_ref
end