The SubtleCrypto.decrypt() method returns a Promise of the cleartext corresponding to the ciphertext, algorithm and key given as parameters.
Syntax
var result = crypto.decrypt(algo, key, ciphertext);
Parameters
ciphertextis aArrayBufferor anArrayBufferViewcontaining the data to be decrypted, the ciphertext.keyis aCryptoKeycontaining the key to be used for decryption.algois aDOMStringdefining the decryption function to use. Supported values are:AES-CBC,AES-CTR,AES-GCM, andRSA-OAEP.
Return value
resultis aPromisethat returns the cleartext generated by the decryption of the ciphertext.
Exceptions
The promise is rejected when the following exception is encountered:
InvalidAccessErrorwhen the encryption key is not a key for the requested decryption algorithm or when trying to use an algorithm that is either unknown or isn't suitable for decryption.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Cryptography API The definition of 'SubtleCrypto.decrypt()' in that specification. |
Candidate Recommendation | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 37 | 34 (34) | Not supported | ? | Not supported |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | 37 | 34.0 (34) | Not supported | ? | Not supported |
See also
CryptoandCrypto.subtle.SubtleCrypto, the interface it belongs to.