CryptoKeyPair
TheCryptoKeyPair dictionary of theWeb Crypto API represents a key pair for an asymmetric cryptography algorithm, also known as a public-key algorithm.
ACryptoKeyPair object can be obtained usingSubtleCrypto.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 bothCryptoKey objects: aprivateKey property containing the private key and apublicKey property containing the public key.
In this article
Instance properties
CryptoKeyPair.privateKeyA
CryptoKeyobject 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.CryptoKeyPair.publicKeyA
CryptoKeyobject 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.
Examples
The examples forSubtleCrypto methods often useCryptoKeyPair objects. For example:
Specifications
| Specification |
|---|
| Web Cryptography Level 2> # keypair> |