Node crypto.sign function | API Reference | Bun
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
signFsign
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
node:crypto/
signFsign
function
crypto.signfunction
sign(algorithm: undefined | null | string,data: ArrayBufferView,key:
KeyLike |
SignKeyObjectInput |
SignPrivateKeyInput |
SignJsonWebKeyInput): NonSharedBuffer;
Calculates and returns the signature for data using the given private key and algorithm. If algorithm is null or undefined, then the algorithm is dependent upon the key type.
algorithm is required to be null or undefined for Ed25519, Ed448, and ML-DSA.
If key is not a KeyObject, this function behaves as if key had been passed to createPrivateKey. If it is an object, the following additional properties can be passed:
If the callback function is provided this function uses libuv's threadpool.
function
sign(algorithm: undefined | null | string,data: ArrayBufferView,key:
KeyLike |
SignKeyObjectInput |
SignPrivateKeyInput |
SignJsonWebKeyInput,callback: (error: null |
Error, data: NonSharedBuffer) => void): void;
Calculates and returns the signature for data using the given private key and algorithm. If algorithm is null or undefined, then the algorithm is dependent upon the key type.
algorithm is required to be null or undefined for Ed25519, Ed448, and ML-DSA.
If key is not a KeyObject, this function behaves as if key had been passed to createPrivateKey. If it is an object, the following additional properties can be passed:
If the callback function is provided this function uses libuv's threadpool.
Referenced typestype
KeyLike = string |
Buffer |
KeyObjectinterface
SignKeyObjectInputcontext?:
ArrayBuffer | ArrayBufferViewArrayBufferLike>
dsaEncoding?:
DSAEncodingkey:
KeyObjectpadding?: number
saltLength?: numberinterface
SignPrivateKeyInputcontext?:
ArrayBuffer | ArrayBufferViewArrayBufferLike>
dsaEncoding?:
DSAEncodingencoding?: string
format?:
KeyFormatkey: string |
BufferArrayBufferLike>
padding?: number
passphrase?: string |
BufferArrayBufferLike>
saltLength?: number
type?:
PrivateKeyExportTypeinterface
SignJsonWebKeyInputcontext?:
ArrayBuffer | ArrayBufferViewArrayBufferLike>
dsaEncoding?:
DSAEncodingformat: 'jwk'
key:
JsonWebKeypadding?: number
saltLength?: number
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →