The SubtleCrypto.verify() method returns a Promise of a Boolean value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters.
Syntax
var result = crypto.verify(algo, key, signature, text2verify);
Parameters
signatureis aArrayBufferor anArrayBufferViewcontaining the signature to verify.text2verifyis aArrayBufferor anArrayBufferViewcontaining the data whose signature as to be verified.keyis aCryptoKeycontaining the key to be used to verify the signature. It is the secret key for a symmetric algorithm and the public key for an asymmetric algorithm.algois aDOMStringdefining the signature function to use. Supported values are:HMAC,RSASSA-PKCS1-v1_5, andECDSA.
Return value
resultis aPromisethat returns aBooleanindicating if the signature has been a success on success.
Exceptions
The promise is rejected when the following exception is encountered:
InvalidAccessErrorwhen the encryption key is not a key for the requested verifying algorithm or when trying to use an algorithm that is either unknown or isn't suitable for a verify operation.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Cryptography API The definition of 'SubtleCrypto.verify()' in that specification. |
Candidate Recommendation | Initial definition. |
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 37 | (Yes) | 34 (34) | No support | ? | No support |
| Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | 37 | (Yes) | 34.0 (34) | No support | ? | No support |
See also
CryptoandCrypto.subtle.SubtleCrypto, the interface it belongs to.