Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil). Junte-se a nós e ajude-nos a fazer o trabalho!
Você também pode ler o artigo em English (US).

The SubtleCrypto.sign() method returns a Promise containing the signature corresponding to the text, algorithm and key given as parameters.

Syntax

var signature = crypto.subtle.sign(algorithm, key, text2sign);

Parameters

  • algorithm is an object specifying the signature function to be used and its parameters; if there are no parameters, algorithm can be a DOMString with the algorithm name. Supported values are: HMAC, RSASSA-PKCS1-v1_5, and ECDSA.
  • key is a CryptoKey containing the private key to be used for signing.
  • text2sign is a ArrayBuffer or an ArrayBufferView containing the data to be signed.

Return value

  • signature is a Promise that returns the signature on success.

Exceptions

The promise is rejected when the following exception is encountered:

  • InvalidAccessError when the signing key is not a key for the request signing algorithm or when trying to use an algorithm that is either unknown or isn't suitable for signing.

Specifications

Specification Status Comment
Web Cryptography API
The definition of 'SubtleCrypto.sign()' in that specification.
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 37Edge Full support 12Firefox Full support 34
Full support 34
No support 32 — 34
Disabled
Disabled From version 32 until version 34 (exclusive): this feature is behind the dom.webcrypto.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
IE Partial support 11
Notes
Partial support 11
Notes
Notes Returns CryptoOperation instead of Promise
Opera Full support 24Safari Full support 7WebView Android Full support 37Chrome Android Full support 37Edge Mobile Full support 12Firefox Android Full support 34
Full support 34
No support 32 — 34
Disabled
Disabled From version 32 until version 34 (exclusive): this feature is behind the dom.webcrypto.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Opera Android Full support 24Safari iOS Full support 7Samsung Internet Android Full support 6.0

Legend

Full support  
Full support
Partial support  
Partial support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Etiquetas do documento e colaboradores

Colaboradores desta página: jvmccarthy, fscholz, Dans24, abbycar, groovecoder, dskloet, teoli
Última atualização por: jvmccarthy,