Sha256: 52f0ca715dc1a49797d5e0f4e103b25c48de296edf2c820776f46c361165bceb

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

#encoding UTF-8
require 'base64'
require 'openssl'
require 'date'

module Fernet
  class Generator
    attr_accessor :message

    def initialize(opts)
      @secret  = opts.fetch(:secret)
      @message = opts[:message]
      @iv      = opts[:iv]
      @now     = opts[:now]
    end

    def generate
      yield self if block_given?

      token = Token.generate(secret:  @secret,
                             message: @message,
                             iv:      @iv,
                             now:     @now)
      token.to_s
    end

    def inspect
      "#<Fernet::Generator @secret=[masked] @message=#{@message.inspect}>"
    end
    alias to_s inspect

    def data=(message)
      puts "[WARNING] 'data' is deprecated, use 'message' instead"
      @message = message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fernet-2.0.rc1 lib/fernet/generator.rb