The Web Crypto API is an interface allowing a script to use cryptographic primitives in order to build systems using cryptography.
Warning: The Web Crypto API provides a number of low-level cryptographic primitives. It's very easy to misuse them, and the pitfalls involved can be very subtle.
Even assuming you use the basic cryptographic functions correctly, secure key management and overall security system design are extremely hard to get right, and are generally the domain of specialist security experts.
Errors in security system design and implementation can make the security of the system completely ineffective.
If you're not sure you know what you are doing, you probably shouldn't be using this API.
Interfaces
Some browsers implemented an interface called Crypto
without having it well defined or being cryptographically sound. In order to avoid confusion, methods and properties of this interface have been removed from browsers implementing the Web Crypto API, and all Web Crypto API methods are available on a new interface: SubtleCrypto
. The Crypto.subtle
property gives access to an object implementing it.
Specifications
Specification | Status | Comment |
---|---|---|
Web Cryptography API | Recommendation | Initial definition |
Browser compatibility
Crypto
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Crypto | Chrome Full support 11 | Edge Full support 12 | Firefox Full support 26 | IE Full support 11 | Opera Full support 15 | Safari Full support 6.1 | WebView Android Full support Yes | Chrome Android Full support 18 | Firefox Android Full support 26 | Opera Android Full support 14 | Safari iOS Full support 6.1 | Samsung Internet Android Full support 1.0 |
getRandomValues() | Chrome Full support 11 | Edge Full support 12 | Firefox Full support 26 | IE Full support 11 | Opera Full support 15 | Safari Full support 6.1 | WebView Android Full support ≤37 | Chrome Android Full support 18 | Firefox Android Full support 26 | Opera Android Full support 14 | Safari iOS Full support 6.1 | Samsung Internet Android Full support 1.0 |
subtle | Chrome Full support 37 | Edge Full support 12 | Firefox
Full support
34
| IE Partial support 11 | Opera Full support 24 | Safari
Full support
10.1
| WebView Android Full support 37 | Chrome Android Full support 37 | Firefox Android
Full support
34
| Opera Android Full support 24 | Safari iOS
Full support
10.3
| Samsung Internet Android Full support 3.0 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.