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

ECDH.convertKey method | Node.js crypto module | Bun

ECDH.convertKey method | Node.js crypto module | BunBuildDocsReferenceGuidesBlogDiscord/node:crypto/ECDH/convertKeyMconvertKey

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:crypto/ECDH/convertKeyMconvertKey

method

crypto.ECDH.convertKeystatic convertKey(key: BinaryLike,curve: string,inputEncoding?: BinaryToTextEncoding,outputEncoding?: 'latin1' | 'base64' | 'base64url' | 'hex',format?: 'uncompressed' | 'compressed' | 'hybrid'): string | NonSharedBuffer;

Converts the EC Diffie-Hellman public key specified by key and curve to the format specified by format. The format argument specifies point encoding and can be 'compressed', 'uncompressed' or 'hybrid'. The supplied key is interpreted using the specified inputEncoding, and the returned key is encoded using the specified outputEncoding.

Use getCurves to obtain a list of available curve names. On recent OpenSSL releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve.

If format is not specified the point will be returned in 'uncompressed' format.

If the inputEncoding is not provided, key is expected to be a Buffer, TypedArray, or DataView.

Example (uncompressing a key):

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

const ecdh = createECDH('secp256k1');
ecdh.generateKeys();

const compressedKey = ecdh.getPublicKey('hex', 'compressed');

const uncompressedKey = ECDH.convertKey(compressedKey,
'secp256k1',
'hex',
'hex',
'uncompressed');

// The converted key and the uncompressed public key should be the same
console.log(uncompressedKey === ecdh.getPublicKey('hex'));
@param inputEncoding

The encoding of the key string.

@param outputEncoding

The encoding of the return value.

Referenced typestype BinaryLike = string | NodeJS.ArrayBufferViewtype BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary'

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 →

ECDH.convertKey method | Node.js crypto module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method node:crypto.ECDH.convertKey | Bun