module Util

Public Class Methods

encrypt(key, data) click to toggle source

method for encryption algorithm

# File lib/rave_ruby/rave_modules/util.rb, line 16
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_generator() click to toggle source

method to generate merchants transaction reference

# File lib/rave_ruby/rave_modules/util.rb, line 10
def self.transaction_reference_generator
  transaction_ref = "MC-" + SecureRandom.hex
  return transaction_ref
end