CryptoKeyPair

CryptoKeyPair dictionary of the Web 加密 API represents a key pair for an asymmetric cryptography algorithm, also known as a public-key algorithm.

A CryptoKeyPair object can be obtained using SubtleCrypto.generateKey() , when the selected algorithm is one of the asymmetric algorithms: RSASSA-PKCS1-v1_5, RSA-PSS, RSA-OAEP, ECDSA, or ECDH.

It contains two properties, which are both CryptoKey objects: a privateKey property containing the private key and a publicKey property containing the public key.

特性

CryptoKey.privateKey
A CryptoKey object representing the private key. For encryption and decryption algorithms, this key is used to decrypt. For signing and verification algorithms it is used to sign.
CryptoKey.publicKey
A CryptoKey object representing the public key. For encryption and decryption algorithms, this key is used to encrypt. For signing and verification algorithms it is used to verify signatures.

范例

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

规范

规范 状态 Comment
Web Cryptography API
The definition of 'CryptoKeyPair' 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
CryptoKeyPair Chrome 37 Edge ≤18 Firefox 34 IE No Opera ? Safari No WebView Android 37 Chrome Android 37 Firefox Android 34 Opera Android ? Safari iOS No Samsung Internet Android 3.0

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知

另请参阅