Class: Egalite::Keitai::URLSession

Inherits:
Object
  • Object
show all
Defined in:
lib/egalite/keitai/keitai.rb

Class Method Summary collapse

Class Method Details

.decrypt(s, key) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/egalite/keitai/keitai.rb', line 17

def self.decrypt(s,key)
  cipher = OpenSSL::Cipher.new("bf-cbc")
  cipher.pkcs5_keyivgen(key)
  cipher.decrypt
  e = s.tr('_.-','+/=')
  e = Base64.decode64(e)
  d = cipher.update(e) + cipher.final
  d
end

.encrypt(s, key) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/egalite/keitai/keitai.rb', line 10

def self.encrypt(s,key)
  cipher = OpenSSL::Cipher.new("bf-cbc")
  cipher.pkcs5_keyivgen(key)
  cipher.encrypt
  e = cipher.update(s) + cipher.final
  Base64.encode64(e).tr('+/=','_.-').gsub!("\n","")
end