CryptoKey

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers .

CryptoKey interface of the Web 加密 API represents a cryptographic key obtained from one of the SubtleCrypto methods generateKey() , deriveKey() , importKey() ,或 unwrapKey() .

For security reasons, the CryptoKey interface can only be used in a secure context .

特性

CryptoKey.type

String which may take one of the following values:

CryptoKey.extractable

Boolean indicating whether or not the key may be extracted using SubtleCrypto.exportKey() or SubtleCrypto.wrapKey() .

  • true : The key may be extracted.
  • false The key may not be extracted. exportKey() or wrapKey() will throw an exception if used to extract this key.
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:

范例

The examples for SubtleCrypto methods often use CryptoKey objects. For example:

规范

规范 状态 Comment
Web Cryptography API
The definition of 'CryptoKey' in that specification.
Recommendation 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
CryptoKey Chrome 37 Edge ≤18 Firefox 34 IE No Opera Yes Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android Yes Safari iOS No Samsung Internet Android 3.0
algorithm Chrome 37 Edge 12 Firefox 34 IE No Opera Yes Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android Yes Safari iOS No Samsung Internet Android 3.0
extractable Chrome 37 Edge 12 Firefox 34 IE No Opera Yes Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android Yes Safari iOS No Samsung Internet Android 3.0
Secure context required Chrome 60 Edge 79 Firefox 75 IE No Opera 47 Safari No WebView Android 60 Chrome Android 60 Firefox Android No Opera Android 47 Safari iOS No Samsung Internet Android No
type Chrome 37 Edge 12 Firefox 34 IE No Opera Yes Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android Yes Safari iOS No Samsung Internet Android 3.0
usages Chrome 37 Edge 12 Firefox 34 IE No Opera Yes Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android Yes Safari iOS No Samsung Internet Android 3.0

图例

完整支持
完整支持
不支持
不支持

另请参阅