Fsign
Bun

function

crypto.sign

function sign(
algorithm: undefined | null | string,
data: ArrayBufferView,
): Buffer;

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,
callback: (error: null | Error, data: Buffer) => 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.