Skip to content
class method

OpenSSL::Digest.new

(::String name, ?::String data) -> ::OpenSSL::Digest
Digest.new(string [, data]) → Digest

Creates a Digest instance based on string, which is either the ln (long name) or sn (short name) of a supported digest algorithm. A list of supported algorithms can be obtained by calling OpenSSL::Digest.digests.

If data (a String) is given, it is used as the initial input to the Digest instance, i.e.

Example
digest = OpenSSL::Digest.new('sha256', 'digestdata')

is equivalent to

Example
digest = OpenSSL::Digest.new('sha256')
digest.update('digestdata')
See also .digests #<< .digest #block_length also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0