Skip to content

Instantly share code, notes, and snippets.

@cendyne
cendyne / example-hkdf.js
Last active January 30, 2023 16:09
HKDF derive key web crypto subtle
// We generated this above as an example IND key derivation key
let openSSLSecretKey = '0de81e851cd7995626ad4c3e160ae1c449af4e15c8ceabd44fb75be581adfbaa';
// Parse the hex string into a Uint8Array
let ikm = Uint8Array.from(openSSLSecretKey
.match(/.{1,2}/g)
.map((byte) => parseInt(byte, 16)));
// Import the raw key data
let kdk = await crypto.subtle.importKey(