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

Node crypto.getDiffieHellman function | API Reference | Bun

Node crypto.getDiffieHellman function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:crypto/getDiffieHellmanFgetDiffieHellman

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:crypto/getDiffieHellmanFgetDiffieHellman

function

crypto.getDiffieHellmanfunction getDiffieHellman(groupName: string): DiffieHellmanGroup;

Creates a predefined DiffieHellmanGroup key exchange object. The supported groups are listed in the documentation for DiffieHellmanGroup.

The returned object mimics the interface of objects created by createDiffieHellman, but will not allow changing the keys (with diffieHellman.setPublicKey(), for example). The advantage of using this method is that the parties do not have to generate nor exchange a group modulus beforehand, saving both processor and communication time.

Example (obtaining a shared secret):

const {
getDiffieHellman,
} = await import('node:crypto');
const alice = getDiffieHellman('modp14');
const bob = getDiffieHellman('modp14');

alice.generateKeys();
bob.generateKeys();

const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex');
const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex');

// aliceSecret and bobSecret should be the same
console.log(aliceSecret === bobSecret);
Referenced typestype DiffieHellmanGroup = OmitDiffieHellman, 'setPublicKey' | 'setPrivateKey'>

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.getDiffieHellman function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:crypto.getDiffieHellman | Bun