module
Digest::ClassMethods
Overview
TheDigest::ClassMethods module is used in the concrete subclass ofDigest
that does not require arguments in its construction.
The modules adds convenient class methods asDigest::MD5.digest,Digest::MD5.hexdigest.
Defined in:
digest/digest.crInstance Method Summary
-
#base64digest(data) : String
Returns the base64-encoded hash ofdata.
-
#base64digest(& : self -> _) : String
Yields a context object with an
#update(data : String | Bytes)method available. -
#digest(data) : Bytes
Returns the hash ofdata.
-
#digest(& : self -> ) : Bytes
Yields an instance of
selfwhich can receive calls to#update(data : String | Bytes)and returns the finalized digest afterwards. -
#hexdigest(data) : String
Returns the hexadecimal representation of the hash ofdata.
-
#hexdigest(& : self -> ) : String
Yields a context object with an
#update(data : String | Bytes)method available.
Instance Method Detail
Returns the base64-encoded hash ofdata.
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="
Yields an instance ofself 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.hexstring # => "acbd18db4cc2f85cedef654fccc4a4d8"
Returns the hexadecimal representation of the hash ofdata.
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"