Class: Mixlib::Authentication::Digester
- Inherits:
-
Object
- Object
- Mixlib::Authentication::Digester
- Defined in:
- lib/mixlib/authentication/digester.rb
Class Method Summary collapse
- .hash_file(f, digest = OpenSSL::Digest::SHA1) ⇒ Object
-
.hash_string(str, digest = OpenSSL::Digest::SHA1) ⇒ Object
Digests a string, base64’s and chomps the end.
Class Method Details
.hash_file(f, digest = OpenSSL::Digest::SHA1) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/mixlib/authentication/digester.rb', line 27 def hash_file(f, digest = OpenSSL::Digest::SHA1) digester = digest.new buf = "" while f.read(16384, buf) digester.update buf end ::Base64.encode64(digester.digest).chomp end |
.hash_string(str, digest = OpenSSL::Digest::SHA1) ⇒ Object
Digests a string, base64’s and chomps the end
Parameters
40 41 42 |
# File 'lib/mixlib/authentication/digester.rb', line 40 def hash_string(str, digest = OpenSSL::Digest::SHA1) ::Base64.encode64(digest.digest(str)).chomp end |