Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SHA256 = Digester{ Key: "sha-256", HashFunc: sha256.New, MaxBytes: 10485760, }
SHA256 is a digester which uses the SHA256 hashing algorithm and key, with MaxBytes set to 10MB.
var SHA384 = Digester{ Key: "sha-384", HashFunc: sha512.New384, MaxBytes: 10485760, }
SHA384 is a digester which uses the SHA384 hashing algorithm and key, with MaxBytes set to 10MB.
var SHA512 = Digester{ Key: "sha-512", HashFunc: sha512.New, MaxBytes: 10485760, }
SHA512 is a digester which uses the SHA512 hashing algorithm and key, with MaxBytes set to 10MB.
Functions ¶
This section is empty.
Types ¶
type Digester ¶
type Digester struct { // Key to give the digest. Key string // HashFunc is a function which returns the hashing algorithm to use. HashFunc func() hash.Hash // MaxBytes is the limit of bytes to read to prevent DOS attacks. MaxBytes int64 }
Digester creates a HTTP request digest in the format specified by https://www.rfc-editor.org/rfc/rfc9530.html#content-digest.
func (Digester) HashRequest ¶
HashRequest hashes a HTTP request and returns a string following the specification in https://www.rfc-editor.org/rfc/rfc9530.html#content-digest
Hashing is performed by reading the HTTP request into memory. To prevent DOS, a http.MaxBytesReader is used to limit the body size that can be read.
'w' is used to signal to the Go HTTP library that a connection should be closed if the client is exceeding the maximum bytes. When using this client-side, 'w' may be set to nil.