Sha256: 7136e9bc713730990814139c3462663fb31de2d2a848304bf6cce9861cb4fd28
Contents?: true
Size: 697 Bytes
Versions: 15
Compression:
Stored size: 697 Bytes
Contents
module Passkit class UrlEncrypt class << self 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 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 private def encryption_key Rails.application.secret_key_base[0..15] end def cypher OpenSSL::Cipher.new("AES-128-CBC") end end end end
Version data entries
15 entries across 15 versions & 1 rubygems