class Rack::Auth::Digest::Nonce
def self.parse(string)
def self.parse(string) new(*Base64.decode64(string).split(' ', 2)) end
def digest
def digest ::Digest::MD5.hexdigest("#{@timestamp}:#{self.class.private_key}") end
def fresh?
def fresh? !stale? end
def initialize(timestamp = Time.now, given_digest = nil)
def initialize(timestamp = Time.now, given_digest = nil) @timestamp, @given_digest = timestamp.to_i, given_digest end
def stale?
def stale? !self.class.time_limit.nil? && (Time.now.to_i - @timestamp) > self.class.time_limit end
def to_s
def to_s Base64.encode64("#{@timestamp} #{digest}").strip end
def valid?
def valid? digest == @given_digest end