Create and verify content digests as found in HTTP headers according to draft-ietf-httpbis-digest-headers
npm install httpbis-digest-headersjs
import { createContentDigestHeader } from 'httpbis-digest-headers';
request.setHeader('Content-Digest', createContentDigestHeader(messageBody, ['sha-256']))
`
$3
`js
import { verifyContentDigest } from 'httpbis-digest-headers';
const server = http.createServer(async (req, res) => {
const buffers = [];
for await (const chunk of req) {
buffers.push(chunk);
}
const verified = verifyContentDigest(Buffer.concat(buffers), req.getHeader('Content-Digest'))
});``