crypto.sign(algorithm, data, key)
algorithm{string | null | undefined}data{Buffer | TypedArray | DataView}key{Object | string | Buffer | KeyObject}- Returns: {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 (especially Ed25519 and Ed448).
If key is not a [KeyObject][], this function behaves as if key had been
passed to [crypto.createPrivateKey()][]. If it is an object, the following
additional properties can be passed:
dsaEncoding{string} For DSA and ECDSA, this option specifies the format of the generated signature. It can be one of the following:'der'(default): DER-encoded ASN.1 signature structure encoding(r, s).'ieee-p1363': Signature formatr || sas proposed in IEEE-P1363.
padding{integer} Optional padding value for RSA, one of the following:crypto.constants.RSA_PKCS1_PADDING(default)crypto.constants.RSA_PKCS1_PSS_PADDING
RSA_PKCS1_PSS_PADDINGwill use MGF1 with the same hash function used to sign the message as specified in section 3.1 of [RFC 4055][].saltLength{integer} Salt length for when padding isRSA_PKCS1_PSS_PADDING. The special valuecrypto.constants.RSA_PSS_SALTLEN_DIGESTsets the salt length to the digest size,crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN(default) sets it to the maximum permissible value.
Feedback
Was this page helpful?
很高兴听到! 请告诉我们,我们如何才能改善.
很遗憾听到这个消息。 请告诉我们,我们如何才能改善.