lib/fernet/token.rb in fernet-2.1 vs lib/fernet/token.rb in fernet-2.1.1

- old
+ new

@@ -79,11 +79,12 @@ message: opts[:message], iv: opts[:iv] ) issued_timestamp = (opts[:now] || Time.now).to_i - payload = [DEFAULT_VERSION].pack("C") + + version = opts[:version] || DEFAULT_VERSION + payload = [version].pack("C") + BitPacking.pack_int64_bigendian(issued_timestamp) + iv + encrypted_message mac = OpenSSL::HMAC.digest('sha256', secret.signing_key, payload) new(Base64.urlsafe_encode64(payload + mac), secret: opts.fetch(:secret)) @@ -146,11 +147,10 @@ iv + encrypted_message end def valid_base64? - decoded_token - true + !decoded_token.nil? rescue ArgumentError false end def signatures_match?