1.2.1 • Published 2 years ago

@panva/hkdf v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

hkdf

HKDF with no dependencies using runtime's native crypto

HKDF is a simple key derivation function defined in RFC 5869.

Documentation

hkdf(digest, ikm, salt, info, keylen): Promise<Uint8Array>

The given ikm, salt and info are used with the digest to derive a key of keylen bytes.

Parameters

NameTypeDescription
digest"sha256" | "sha384" | "sha512" | "sha1"The digest algorithm to use.
ikmUint8Array | stringThe input keying material. It must be at least one byte in length.
saltUint8Array | stringThe salt value. Must be provided but can be zero-length.
infoUint8Array | stringAdditional info value. Must be provided but can be zero-length, and cannot be more than 1024 bytes.
keylennumberThe length in bytes of the key to generate. Must be greater than 0 and no more than 255 times the digest size.

Returns

Promise<Uint8Array>

Example

example ESM import

import hkdf from '@panva/hkdf'

example CJS import

const { hkdf } = require('@panva/hkdf')

example Deno import

import hkdf from 'https://deno.land/x/hkdf/index.ts'

example Usage

const derivedKey = await hkdf(
  'sha256',
  'key',
  'salt',
  'info',
  64
)

Supported Runtimes

The supported JavaScript runtimes include ones that

  • are reasonably up to date ECMAScript
  • support the utilized Web API globals and standard built-in objects
  • These are
    • (This is not an exhaustive list)
    • Browsers
    • Cloudflare Workers
    • Deno
    • Electron
    • Netlify Edge Functions
    • Next.js Middlewares
    • Node.js
    • Vercel Edge Functions
@infinitebrahmanuniverse/nolb-_panv@puyodead1/next-auth@everything-registry/sub-chunk-704@wolfleader101/nextjs-auth0@willmitchell/authjs-core@tru_id/next-auth@thewilloftheshadow/next-auth-fork@tiplink/next-auth@vinhnguyen1211/next-auth@zacarycarter/nextjs-auth0amee@zoomit/next-authauth-apple-fix-coreaponiafauthy-next-sdkbytevane-authchidu-authentication-moduledamienpm-next-authbeak8-next-authbrazy-auth@dennishellernokia/next-authnext-auth-modifiedspkf-next-auth@auth-pp/corezihan-auth-core@emulienfou/auth-core@eartho/one-client-nextjs@putao520/next-authmoxieauth-coremfkdfnext-auth-danger-linknext-auth-fork-bodyaalyas12next-auth-imrdjainext-auth-jwt-fixnext-auth-sescnext-auth-siwenext-auth-testnext-auth-with-exponext-authnext-auth-sanitizenext-auth-override-redirectnext-auth-patch-feature-nonce-checknext-auth-preconysnext-auth-linkedin-fixnextauth-jwe-decryptpickaxe-next-authrkang-auth-core@stevesouth/next-auth@stringke/next-auth@suptreze/shared@korol-oleksandr-hoc/auth-middleware@nixcode/next-auth@ninepie/jwt@sse-auth/backend@sse-auth/utils@nhi/next-auth@pixel-point/next-auth@pluv/io@polymorf3d/next-auth@oviava/authjs-nuxt@524c/auth-core@proselog/jwt@alexanderlee/next-auth@big-pixel-media/nuxt-auth@cgps/next-auth@authok/nextjs-authok@bangdinhnpm/next-auth@baladesh/next-auth@awwong1/nextjs-auth0@auth0/mdl@auth0/nextjs-auth0@auth/core@answeroverflow/next-auth@alphanovatech/nextjs-auth0@alpakaslab/nextjs-jwt-auth@aponia.js/core@aoeu/next-auth@cs125/mace@cs124/mace@conductorai/auth-core@coherence-finance/next-auth@codetheorist/next-auth@dataparty/crypto@dbcdk/decrypt-jwt-token@dbcdk/set-jwt-expiration-date@devancej/core@digital-realty/auth-core@dicksonp/auth-core@devsen/auth-core@dts-stn/next-auth@neon.id/identitas-operation@egoist/jwt@edge-store/react@edge-store/server@edgestore/react@eicrud/core@edgestore/server@greenrenge/playbux-next-auth@ibercore/next-auth@hebilicious/authjs-nuxt
1.2.0

2 years ago

1.2.1

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago