module Digest
Digest: message digests (SHA-256, MD5), HMAC-SHA-256 and PBKDF2.
require "digest"
Digest::SHA256.hexdigest("abc")[0, 16] # => "ba7816bf8f01cfea"
Digest::HMAC.sha256("key", "message").size # => 32
Each function takes its data as Bytes or as a String (its UTF-8
bytes) and gives the digest as Bytes, or as lowercase hexadecimal from
hexdigest.
Classes and modules
Digest::HMACHMAC (RFC 2104).Digest::MD5MD5 (RFC 1321). Broken as a cryptographic hash: here for protocols that still use it, such as PostgreSQL's md5 authentication.Digest::PBKDF2PBKDF2 (RFC 8018), the key derivation of SCRAM and of password storage.Digest::SHA256SHA-256 (FIPS 180-4).