module HTTPSignatures::Digest
The Digest header of RFC 3230 with its SHA-256 algorithm: what a
signature covers to cover the body.
HTTPSignatures::Digest.header('{"hello": "world"}')
# => "SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE="
HTTPSignatures::Digest.matches?("sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=", '{"hello": "world"}')
# => true
Class methods
def self.header(body: Bytes | String) -> String
The header's value for body (a String's UTF-8 bytes):
SHA-256= and the Base64 of its SHA-256.
def self.sha256(header: String) -> Bytes?
The SHA-256 the header's value gives, or nil when it has no
SHA-256 entry or that entry is not Base64. The value is a list
(SHA-256=…, SHA-512=…); algorithm names are compared without
regard to case.
def self.matches?(header: String, body: Bytes | String) -> Bool
Whether the header's value has a SHA-256 entry that is the SHA-256
of body, compared in constant time.