sign method

Returns an object that can sign data using the specified algorithm and a Key object.

Important  As of Microsoft Edge, this method returns a Promise object. See Web Cryptography API updates for more info.



var retVal = SubtleCrypto.sign(algorithm, key, buffer);


algorithm [in]

Type: any

An object specifying the cryptographic signature or message authentication algorithm to use (along with any required algorithmic parameters).

key [in]

Type: Key

The signing or message authentication key.

buffer [in, optional]

Type: ArrayBufferView

The data to be signed via the key specified by the key parameter. If this parameter is specified, the returned operation will immediately complete and return the signature. Otherwise, the caller is expected to perform the following tasks:

  1. Provide data through any number of calls to the process method of the CryptoOperation object returned by this (sign) method.
  2. Call the finish method (on this same CryptoOperation object) when done entering data via the process method.

Once the above two steps are completed, the operation will be completed and the signature returned.

Return value

Type: Promise

An Promise object that will sign data using the specified algorithm with the supplied key.

Note  IE11 returns a CryptoOperation. See Web Cryptography API updates for more info.


The sign method supports the following cryptographic algorithms:

  • RSASSA-PKCS1-v1_5
  • HMAC

See also