lib/fernet.rb in fernet-1.6 vs lib/fernet.rb in fernet-2.0.rc1
- old
+ new
@@ -1,27 +1,21 @@
require 'fernet/version'
+require 'fernet/bit_packing'
+require 'fernet/encryption'
+require 'fernet/token'
require 'fernet/generator'
require 'fernet/verifier'
require 'fernet/secret'
require 'fernet/configuration'
-if RUBY_VERSION == '1.8.7'
- require 'shim/base64'
-end
-
Fernet::Configuration.run
module Fernet
- def self.generate(secret, encrypt = Configuration.encrypt, &block)
- Generator.new(secret, encrypt).generate(&block)
+ def self.generate(secret, message = '', opts = {}, &block)
+ Generator.new(opts.merge({secret: secret, message: message})).
+ generate(&block)
end
- def self.verify(secret, token, encrypt = Configuration.encrypt, &block)
- Verifier.new(secret, encrypt).verify_token(token, &block)
- end
-
- def self.verifier(secret, token, encrypt = Configuration.encrypt)
- Verifier.new(secret, encrypt).tap do |v|
- v.verify_token(token)
- end
+ def self.verifier(secret, token, opts = {})
+ Verifier.new(opts.merge({secret: secret, token: token}))
end
end