Module: Util

Defined in:
lib/rave_ruby/rave_modules/util.rb

Class Method Summary collapse

Class Method Details

.encrypt(key, data) ⇒ Object

method for encryption algorithm



16
17
18
19
20
21
22
23
24
# 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_generatorObject

method to generate merchants transaction reference



10
11
12
13
# File 'lib/rave_ruby/rave_modules/util.rb', line 10

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