blob: 185532f744dffa2b21cee1cbcd0dc63197c79dc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
require 'mixlib/authentication'
module Mixlib
module Authentication
class Digester
attr_reader :hashed_body
def initialize()
@hashed_body = nil
end
# Compare the request timestamp with boundary time
#
#
# ====Parameters
# time1<Time>:: minuend
# time2<Time>:: subtrahend
#
def hash_file(f)
digester = Digest::SHA1.new
buf = ""
while f.read(16384, buf)
digester.update buf
end
@hashed_body ||= ::Base64.encode64(digester.digest).chomp
end
# Digests the body, base64's and chomps the end
#
#
# ====Parameters
#
def hash_body(body)
@hashed_body ||= ::Base64.encode64(Digest::SHA1.digest(body)).chomp
end
end
end
end
|