Adding Digest Header to API Request using javascript (plugin)

We want to create a Digest Header based on SHA256 calculation.
Normally we use the crypto function in Node, but the javascript available for plugin (via Otto) is very limited.

This is what we would like to run:
const { createHash } = require(‘crypto’) ;
var digest = ‘SHA-256=’ + createHash(‘sha256’).update(body).digest().toString(‘base64’);

Anybody have suggestions how we can produce the digest header as part of a plugin, so we can include it in the API request?

If you want to stay with Node you can use a grpc plugin Create Custom Authentication Plugin with NodeJS

The example is for an a plugin in the authentication hook but you can switch for something like a pre or post plugin depending on needs.