module MbedTLS::DigestBase
Overview
Describes common utility methods for working with message digests.
Direct including types
Defined in:
digest/digest_base.crClass Method Summary
-
.hexdump(digest)
Utility method, converts a buffer slice to a hexadecimal representation.
Instance Method Summary
-
#<<(data)
Shorthand operator for
#update
. -
#base64digest
Returns the Base64 encoded representation of the digest.
-
#digest
Hash the buffer and return the raw bytes returned by the digest algorithm.
-
#file(file_name)
Utility method to read a file into the internal buffer of the
Digest
instance. -
#hexdigest
Returns the hexadecimal representation of the digest.
-
#to_s(io)
Converts digest instance to a string by creating it's hexadecimal representation.
-
#update(io : IO)
Adds the contents of the
io
I/O buffer to the internal buffer of theDigest
instance.
Class Method Detail
Instance Method Detail
Shorthand operator for #update
.
You can chain the <<
operator to concatenate data into the
internal buffer of the Digest
instance for hashing.
require "mbedtls"
digest = MbedTLS::Digest::SHA256.new
digest << "Hello, world"
puts "SHA256(Hello, world) = #{digest}"
Output:
SHA256(Hello, world) = 4ae7c3b6ac0beff671efa8cf57386151c06e58ca53a78d83f36107316cec125f
Utility method to read a file into the internal buffer of the
Digest
instance.