Sha256: 564203d79ab2196806e5e6f5b52acd3600cb8d2720ac6ec8f12faa7693f6576b
Contents?: true
Size: 443 Bytes
Versions: 1
Compression:
Stored size: 443 Bytes
Contents
require 'base64' require 'json' require 'openssl' require 'date' module Fernet class Generator attr_reader :secret attr_accessor :data def initialize(secret) @secret = secret end def generate yield self data.merge!(issued_at: DateTime.now) mac = OpenSSL::HMAC.hexdigest('sha256', JSON.dump(data), secret) Base64.urlsafe_encode64(JSON.dump(data.merge(signature: mac))) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fernet-0.0.1 | lib/fernet/generator.rb |