CryptoKey
Web Crypto API
Web Crypto API
The **`CryptoKey`** interface of the [Web Crypto API](/docs/Web/API/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](/docs/Web/Security/Defenses/Secure_Contexts).
## Instance properties
- CryptoKey.type
- : The type of key the object represents. It may take one of the following values: `"secret"`, `"private"` or `"public"`.
- CryptoKey.extractable
- : A boolean value indicating whether or not the key may be extracted using [`SubtleCrypto.exportKey()`](/docs/Web/API/SubtleCrypto/exportKey) or [`SubtleCrypto.wrapKey()`](/docs/Web/API/SubtleCrypto/wrapKey).
- CryptoKey.algorithm
- : An object describing the algorithm for which this key can be used and any associated extra parameters.
- CryptoKey.usages
- : 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:
- [`SubtleCrypto.generateKey()`](/docs/Web/API/SubtleCrypto/generateKey)
- [`SubtleCrypto.deriveKey()`](/docs/Web/API/SubtleCrypto/deriveKey)
- [`SubtleCrypto.importKey()`](/docs/Web/API/SubtleCrypto/importKey)
- [`SubtleCrypto.exportKey()`](/docs/Web/API/SubtleCrypto/exportKey)
- [`SubtleCrypto.wrapKey()`](/docs/Web/API/SubtleCrypto/wrapKey)
- [`SubtleCrypto.unwrapKey()`](/docs/Web/API/SubtleCrypto/unwrapKey)
- [`SubtleCrypto.encrypt()`](/docs/Web/API/SubtleCrypto/encrypt)
- [`SubtleCrypto.decrypt()`](/docs/Web/API/SubtleCrypto/decrypt)
- [`SubtleCrypto.sign()`](/docs/Web/API/SubtleCrypto/sign)
- [`SubtleCrypto.verify()`](/docs/Web/API/SubtleCrypto/verify)
## Specifications
## Browser compatibility
## See also
- [Web Crypto API](/docs/Web/API/Web_Crypto_API)
- [Web security](/docs/Web/Security)
- [Privacy, permissions, and information security](/docs/Web/Privacy)
- Crypto and Crypto.subtle.
Cite this
"CryptoKey". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy