CryptoKey - Web APIs 编辑

Secure context

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

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.

Properties

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:

  • "encrypt": The key may be used to encrypt messages.
  • "decrypt": The key may be used to decrypt messages.
  • "sign": The key may be used to sign messages.
  • "verify": The key may be used to verify signatures.
  • "deriveKey": The key may be used in deriving a new key.
  • "deriveBits": The key may be used in deriving bits.
  • "wrapKey": The key may be used to wrap a key.
  • "unwrapKey": The key may be used to unwrap a key.

Examples

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

Specifications

SpecificationStatusComment
Web Cryptography API
The definition of 'CryptoKey' in that specification.
RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:85 次

字数:8557

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文