lib/rack/auth/digest/nonce.rb in rack-2.2.9 vs lib/rack/auth/digest/nonce.rb in rack-2.2.10
- old
+ new
@@ -1,9 +1,8 @@
# frozen_string_literal: true
require 'digest/md5'
-require 'base64'
module Rack
module Auth
module Digest
# Rack::Auth::Digest::Nonce is the default nonce generator for the
@@ -19,18 +18,18 @@
class << self
attr_accessor :private_key, :time_limit
end
def self.parse(string)
- new(*Base64.decode64(string).split(' ', 2))
+ new(*string.unpack("m").first.split(' ', 2))
end
def initialize(timestamp = Time.now, given_digest = nil)
@timestamp, @given_digest = timestamp.to_i, given_digest
end
def to_s
- Base64.encode64("#{@timestamp} #{digest}").strip
+ ["#{@timestamp} #{digest}"].pack("m").strip
end
def digest
::Digest::MD5.hexdigest("#{@timestamp}:#{self.class.private_key}")
end