Sha256: b93dd99801ba92cab4c6c7d035fbd25cc9bc84f63a9328e9cae5d618f20c54a2
Contents?: true
Size: 897 Bytes
Versions: 1
Compression:
Stored size: 897 Bytes
Contents
require "base64" require "json" require 'openssl' module Utils def self.verify_signature(secret, text_body, header_signature) begin key = secret.encode('utf-8') body = text_body.encode('utf-8') calculated_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha512'), key, body) calculated_signature.eql? header_signature rescue Exception return false end end def self.parse_cookie(cookie = nil) fp = "" cid = "" unless cookie return fp, cid end begin decoded_cookie = Base64.decode64(cookie) unless decoded_cookie decoded_cookie = "{}" end jsonified = JSON.generate(decoded_cookie) if jsonified["fp"] fp = jsonified["fp"] end if jsonified["cid"] cid = jsonified["cid"] end rescue Exception ensure return fp, cid end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
securenative-0.1.5 | lib/securenative/utils.rb |