levenhmac

1.0.0 • Public • Published

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.

Note crypto.subtle is a fairly new global, so if you want to use this package, you'll need to be on Node 19 or above.

Warning This polyfill only supports UTF-8 strings and hex digests. If you need anything else, you're on your own.

Installation

npm i createhmac-polyfill

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');

/levenhmac/

    Package Sidebar

    Install

    npm i levenhmac

    Weekly Downloads

    3

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.24 kB

    Total Files

    6

    Last publish

    Collaborators

    • lginxai