Class: Passkit::UrlEncrypt

Inherits:
Object
  • Object
show all
Defined in:
lib/passkit/url_encrypt.rb

Class Method Summary collapse

Class Method Details

.decrypt(string) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/passkit/url_encrypt.rb', line 13

def decrypt(string)
  cipher = cypher.decrypt
  cipher.key = encryption_key
  s = [string].pack("H*").unpack("C*").pack("c*")

  JSON.parse(cipher.update(s) + cipher.final, symbolize_names: true)
end

.encrypt(payload) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/passkit/url_encrypt.rb', line 4

def encrypt(payload)
  string = payload.to_json
  cipher = cypher.encrypt
  cipher.key = encryption_key
  s = cipher.update(string) + cipher.final

  s.unpack1("H*").upcase
end