Module: Netpayclient::Crypto

Defined in:
lib/netpayclient.rb

Class Method Summary collapse

Class Method Details

.cryptoObject



11
12
13
14
15
16
17
18
19
# File 'lib/netpayclient.rb', line 11

def self.crypto
  if defined?(@@crypto).nil?
    @@crypto = Mcrypt.new(:des, :cbc)
    @@crypto.key = DES_KEY
    @@crypto.iv = "\x00" * 8
    @@crypto.padding = false
  end
  @@crypto
end

.decrypt(str) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/netpayclient.rb', line 21

def self.decrypt(str)
  if str.blank?
    "\xEE\xB3\x16\x86\xAB\x84G\x90"
  else
    self.crypto.decrypt(str)
  end
end