polyfill-createhmac
v1.0.0
Published
A small polyfill for the createHmac function in Node.js; meant to be used in Cloudflare Workers but can be used anywhere that has SubtleCrypto.
Downloads
3
Readme
createHmac
Polyfill
Okay. I know what you're thinking. I know this is dumb, but a friend of mine wanted to port their
createHmac
code to work on Cloudflare Workers, and I thought it would be a good idea to make
a polyfill for it.
I highly recommend you use the WebCrypto API directly instead, but this is for the tired souls who are too tired to figure that out. You're free to copy paste this code into your project if you want. Stars are appreciated :D
Warning This polyfill only supports
UTF-8
strings andhex
digests. If you need anything else, you're on your own.
Usage
import { createHmac } from 'createhmac-polyfill';
const hmac = createHmac('sha512', process.env.SECRET);
// acquire data
const data = [...];
hmac.update(data);
const signature = await hmac.digest('hex');