Module: Digest::Instance
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | ext/digest/digest.c, ext/digest/bubblebabble/bubblebabble.c, ext/digest/lib/digest.rb |
Overview
This module provides instance methods for a digest implementation object to calculate message digest values.
Instance Method Summary
-
#<<(string) ⇒ digest_obj
(also: #update)
Updates the digest using a given string and returns self.
-
#==(another_digest_obj) ⇒ Boolean
If a string is given, checks whether it is equal to the hex-encoded hash value of the digest object.
-
#base64digest(str = nil)
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 ⇒ Integer
Returns the block length of the digest.
-
#bubblebabble ⇒ hash_string
Returns the resulting hash value in a Bubblebabble encoded form.
-
#digest ⇒ String
If none is given, returns the resulting hash value of the digest, keeping the digest's state.
-
#digest! ⇒ String
Returns the resulting hash value and resets the digest to the initial state.
-
#digest_length ⇒ Integer
Returns the length of the hash value of the digest.
-
#file(name)
Updates the digest with the contents of a given file name and returns self.
-
#hexdigest ⇒ String
If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest's state.
-
#hexdigest! ⇒ String
Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state.
-
#inspect ⇒ String
Creates a printable version of the digest object.
-
#length ⇒ Integer
(also: #size)
Returns digest_obj.digest_length().
-
#new ⇒ another_digest_obj
Returns a new, initialized copy of the digest object.
-
#reset ⇒ digest_obj
Resets the digest to the initial state and returns self.
-
#size ⇒ Integer
Alias for #length.
-
#to_s ⇒ String
Returns digest_obj.hexdigest().
-
#update(string) ⇒ digest_obj
Alias for #<<.
-
#instance_eval ⇒ digest_obj
private
Finishes the digest and returns the resulting hash value.
Instance Method Details
#update(string) ⇒ digest_obj
#<<(string) ⇒ digest_obj
Also known as: #update
digest_obj
#<<(string) ⇒ digest_obj
Updates the digest using a given string and returns self.
The update() method and the left-shift operator are overridden by each implementation subclass. (One should be an alias for the other)
#==(another_digest_obj) ⇒ Boolean
#==(string) ⇒ Boolean
Boolean
#==(string) ⇒ Boolean
If a string is given, checks whether it is equal to the hex-encoded hash value of the digest object. If another digest instance is given, checks whether they have the same hash value. Otherwise returns false.
#base64digest(str = nil)
If none is given, returns the resulting hash value of the digest in a base64 encoded form, keeping the digest's state.
If a string
is given, returns the hash value for the given string
in a base64 encoded form, resetting the digest to the initial state before and after the process.
In either case, the return value is properly padded with '=' and contains no line feeds.
#base64digest!
Returns the resulting hash value and resets the digest to the initial state.
# File 'ext/digest/lib/digest.rb', line 73
def base64digest! [digest!].pack('m0') end
#block_length ⇒ Integer
Returns the block length of the digest.
This method is overridden by each implementation subclass.
#bubblebabble ⇒ hash_string
Returns the resulting hash value in a Bubblebabble encoded form.
#digest ⇒ String
#digest(string) ⇒ String
String
#digest(string) ⇒ String
If none is given, returns the resulting hash value of the digest, keeping the digest's state.
If a string is given, returns the hash value for the given string, resetting the digest to the initial state before and after the process.
#digest! ⇒ String
Returns the resulting hash value and resets the digest to the initial state.
#digest_length ⇒ Integer
Returns the length of the hash value of the digest.
This method should be overridden by each implementation subclass. If not, digest_obj.digest().length() is returned.
#file(name)
Updates the digest with the contents of a given file name and returns self.
# File 'ext/digest/lib/digest.rb', line 48
def file(name) File.open(name, "rb") {|f| buf = "" while f.read(16384, buf) update buf end } self end
#instance_eval ⇒ digest_obj
(private)
Finishes the digest and returns the resulting hash value.
This method is overridden by each implementation subclass and often made private, because some of those subclasses may leave internal data uninitialized. Do not call this method from outside. Use #digest!() instead, which ensures that internal data be reset for security reasons.
#hexdigest ⇒ String
#hexdigest(string) ⇒ String
String
#hexdigest(string) ⇒ String
If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest's state.
If a string is given, returns the hash value for the given string in a hex-encoded form, resetting the digest to the initial state before and after the process.
#hexdigest! ⇒ String
Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state.
#inspect ⇒ String
Creates a printable version of the digest object.
#length ⇒ Integer
#size ⇒ Integer
Also known as: #size
Integer
#size ⇒ Integer
Returns digest_obj.digest_length().
#new ⇒ another_digest_obj
Returns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset().
#reset ⇒ digest_obj
Resets the digest to the initial state and returns self.
This method is overridden by each implementation subclass.
#length ⇒ Integer
#size ⇒ Integer
Integer
#size ⇒ Integer
Alias for #length.
#to_s ⇒ String
Returns digest_obj.hexdigest().
#update(string) ⇒ digest_obj
#<<(string) ⇒ digest_obj
digest_obj
#<<(string) ⇒ digest_obj
Alias for #<<.