Class: Digest::SHA1
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
|
|
|
Instance Chain:
|
|
| Inherits: |
Digest::Base
|
| Defined in: | ext/digest/sha1/sha1init.c, ext/digest/sha1/sha1init.c |
Overview
A class for calculating message digests using the SHA-1 Secure Hash Algorithm by NIST (the US’ National Institute of Standards and Technology), described in FIPS PUB 180-1.
See Instance for digest API.
SHA-1 calculates a digest of 160 bits (20 bytes).
Examples
require 'digest'
# Compute a complete digest
Digest::SHA1.hexdigest 'abc' #=> "a9993e36..."
# Compute digest by chunks
sha1 = Digest::SHA1.new # =>#<Digest::SHA1>
sha1.update "ab"
sha1 << "c" # alias for #update
sha1.hexdigest # => "a9993e36..."
# Use the same object to compute another digest
sha1.reset
sha1 << "message"
sha1.hexdigest # => "6f9b9af3..."
Class Method Summary
Class - Inherited
| .base64digest | Returns the base64 encoded hash value of a given string. |
| .digest | Returns the hash value of a given string. |
| .file | Creates a digest object and reads a given file, name. |
| .hexdigest | Returns the hex-encoded hash value of a given string. |
| .new | |
Instance Method Summary
Base - Inherited
| #<< | Update the digest using given string and return |
| #block_length | Return the block length of the digest in bytes. |
| #digest_length | Return the length of the hash value in bytes. |
| #reset | Reset the digest to its initial state and return |
| #update | Alias for Base#<<. |
| #initialize_copy, #finish | |
Instance - Included
| #<< | Updates the digest using a given string and returns self. |
| #== | If a string is given, checks whether it is equal to the hex-encoded hash value of the digest object. |
| #base64digest | If none is given, returns the resulting hash value of the digest in a base64 encoded form, keeping the digest’s state. |
| #base64digest! | Returns the resulting hash value and resets the digest to the initial state. |
| #block_length | Returns the block length of the digest. |
| #bubblebabble | Returns the resulting hash value in a Bubblebabble encoded form. |
| #digest | If none is given, returns the resulting hash value of the digest, keeping the digest’s state. |
| #digest! | Returns the resulting hash value and resets the digest to the initial state. |
| #digest_length | Returns the length of the hash value of the digest. |
| #file | Updates the digest with the contents of a given file name and returns self. |
| #hexdigest | If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest’s state. |
| #hexdigest! | Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state. |
| #inspect | Creates a printable version of the digest object. |
| #length | Returns digest_obj.digest_length(). |
| #new | Returns a new, initialized copy of the digest object. |
| #reset | Resets the digest to the initial state and returns self. |
| #size | Alias for Instance#length. |
| #to_s | Returns digest_obj.hexdigest(). |
| #update | Alias for Instance#<<. |
| #finish | Finishes the digest and returns the resulting hash value. |
Constructor Details
This class inherits a constructor from Digest::Class