Digest
Digest is the base type of hashing algorithms like Digest::MD5,
Digest::SHA1, Digest::SHA256, or Digest::SHA512.
A Digest instance holds the state of an ongoing hash calculation.
It can receive new data to include in the hash via #update, #<<, or #file.
Once all data is included, use #final or #hexfinal to get the hash. This will mark the
ongoing calculation as finished. A finished calculation can't receive new data.
A digest.dup.final call may be used to get an intermediate hash value.
Use #reset to reuse the Digest instance for a new calculation.
Instance methods
Reads the file's content and updates the digest with it.
Puts the final digest output into dst.
Faster than the Bytes allocating version.
Use when hashing in loops.
final or hexfinal can only be called once and raises FinalizedError on subsequent calls.
NOTE: .dup.final(dst) call may be used to get an intermediate hash value.
Returns the final digest output.
final or hexfinal can only be called once and raises FinalizedError on subsequent calls.
NOTE: .dup.final call may be used to get an intermediate hash value.
Writes a hexadecimal-encoded digest to dst.
Faster than the String allocating version.
Use when hashing in loops.
final or hexfinal can only be called once and raises FinalizedError on subsequent calls.
NOTE: .dup.final call may be used to get an intermediate hash value.
Writes a hexadecimal-encoded digest to IO.
Faster than the String allocating version.
final or hexfinal can only be called once and raises FinalizedError on subsequent calls.
NOTE: .dup.final call may be used to get an intermediate hash value.
This method is restricted to a maximum digest size of 64 bytes. Implementations that allow a larger digest size should override this method to use a larger buffer.
Returns a hexadecimal-encoded digest in a new String.
final or hexfinal can only be called once and raises FinalizedError on subsequent calls.
NOTE: .dup.hexfinal call may be used to get an intermediate hash value.
Resets the state of this object. Use to get another hash value without creating a new object.