温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/crypto/pbkdf2
点击访问原文链接

Node crypto.pbkdf2 function | API Reference | Bun

Node crypto.pbkdf2 function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:crypto/pbkdf2Fpbkdf2

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:crypto/pbkdf2Fpbkdf2

function

crypto.pbkdf2 { if (err) throw err; console.log(derivedKey.toString('hex')); // '3745e48...08d59ae' }); ``` An array of supported digest functions can be retrieved using getHashes. This API uses libuv's threadpool, which can have surprising and negative performance implications for some applications; see the `UV_THREADPOOL_SIZE` documentation for more information." data-algolia-static="false" data-algolia-merged="false" data-type="Function">function pbkdf2(password: BinaryLike,salt: BinaryLike,iterations: number,keylen: number,digest: string,callback: (err: null | Error, derivedKey: NonSharedBuffer) => void): void;

Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by digest is applied to derive a key of the requested byte length (keylen) from the password, salt and iterations.

The supplied callback function is called with two arguments: err and derivedKey. If an error occurs while deriving the key, err will be set; otherwise err will be null. By default, the successfully generated derivedKey will be passed to the callback as a Buffer. An error will be thrown if any of the input arguments specify invalid values or types.

The iterations argument must be a number set as high as possible. The higher the number of iterations, the more secure the derived key will be, but will take a longer amount of time to complete.

The salt should be as unique as possible. It is recommended that a salt is random and at least 16 bytes long. See NIST SP 800-132 for details.

When passing strings for password or salt, please consider caveats when using strings as inputs to cryptographic APIs.

const {
pbkdf2,
} = await import('node:crypto');

pbkdf2('secret', 'salt', 100000, 64, 'sha512', (err, derivedKey) => {
if (err) throw err;
console.log(derivedKey.toString('hex')); // '3745e48...08d59ae'
});

An array of supported digest functions can be retrieved using getHashes.

This API uses libuv's threadpool, which can have surprising and negative performance implications for some applications; see the UV_THREADPOOL_SIZE documentation for more information.

Referenced typestype BinaryLike = string | NodeJS.ArrayBufferView

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node crypto.pbkdf2 function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:crypto.pbkdf2 | Bun