The CryptoKey interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods generateKey(), deriveKey(), importKey(), or unwrapKey().
For security reasons, the CryptoKey interface can only be used in a secure context.
Instance properties
CryptoKey.type Read only
-
The type of key the object represents. It may take one of the following values: "secret", "private" or "public".
CryptoKey.extractable Read only
-
A boolean value indicating whether or not the key may be extracted using SubtleCrypto.exportKey() or SubtleCrypto.wrapKey().
CryptoKey.algorithm Read only
-
An object describing the algorithm for which this key can be used and any associated extra parameters.
CryptoKey.usages Read only
-
An Array of strings, indicating what can be done with the key. Possible values for array elements are "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", and "unwrapKey".
Examples
The examples for SubtleCrypto methods often use CryptoKey objects. For example:
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
CryptoKey |
37 |
12 |
34 |
No |
24 |
7 |
37 |
37 |
34 |
24 |
7 |
3.0 |
algorithm |
37 |
12 |
34 |
No |
24 |
7 |
37 |
37 |
34 |
24 |
7 |
3.0 |
extractable |
37 |
12 |
34 |
No |
24 |
7 |
37 |
37 |
34 |
24 |
7 |
3.0 |
type |
37 |
12 |
34 |
No |
24 |
7 |
37 |
37 |
34 |
24 |
7 |
3.0 |
usages |
37 |
12 |
34 |
No |
24 |
7 |
37 |
37 |
34 |
24 |
7 |
3.0 |
See also