Implements the MD5 digest algorithm.
Warning: MD5 is no longer a cryptographically secure hash, and should not be used in security-related components, like password hashing. For passwords, see Crypto::Bcrypt::Password
. For a generic cryptographic hash, use SHA-256 via OpenSSL::Digest.new("SHA256")
.
7
12
17
22
5
9
14
20
4
11
16
23
6
10
15
21
Returns the base64-encoded hash of data.
Yields a context object with an #update(data : String | Bytes)
method available.
Returns the hash of data.
Yields an instance of self
which can receive calls to #update(data : String | Bytes)
and returns the finalized digest afterwards.
Returns the hexadecimal representation of the hash of data.
Yields a context object with an #update(data : String | Bytes)
method available.
Returns the digest output size in bytes.
Digest::Base
Reference
Reference
Object
Object
Returns the base64-encoded hash of data.
require "digest/sha1" Digest::SHA1.base64digest("foo") # => "C+7Hteo/D9vJXQ3UfzxbwnXaijM="
Yields a context object with an #update(data : String | Bytes)
method available. Returns the resulting digest in base64 representation afterwards.
require "digest/sha1" Digest::SHA1.base64digest do |ctx| ctx.update "f" ctx.update "oo" end # => "C+7Hteo/D9vJXQ3UfzxbwnXaijM="
Returns the hash of data. data must respond to #to_slice
.
Yields an instance of self
which can receive calls to #update(data : String | Bytes)
and returns the finalized digest afterwards.
require "digest/md5" digest = Digest::MD5.digest do |ctx| ctx.update "f" ctx.update "oo" end digest.to_slice.hexstring # => "acbd18db4cc2f85cedef654fccc4a4d8"
Returns the hexadecimal representation of the hash of data.
require "digest/md5" Digest::MD5.hexdigest("foo") # => "acbd18db4cc2f85cedef654fccc4a4d8"
Yields a context object with an #update(data : String | Bytes)
method available. Returns the resulting digest in hexadecimal representation afterwards.
require "digest/md5" Digest::MD5.hexdigest("foo") # => "acbd18db4cc2f85cedef654fccc4a4d8" Digest::MD5.hexdigest do |ctx| ctx.update "f" ctx.update "oo" end # => "acbd18db4cc2f85cedef654fccc4a4d8"
Returns the digest output size in bytes.
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Digest/MD5.html