generateKey method
Returns a new Promise object which will generate a new key for use with the algorithm specified by the algorithm parameter.
![]() |
Syntax
var retVal = SubtleCrypto.generateKey(algorithm, extractable, keyUsages);Parameters
- algorithm [in]
-
Type: any
An object identifying the cryptographic algorithm with which the generated key will be used (along with any required parameters).
- extractable [in, optional]
-
Type: bool
Whether or not the keying material of the generated key may be exported by the application. The default value is false.
- keyUsages [in, optional]
-
Type: sequence<DOMString>
An array containing one or more of the following DOM strings: encrypt, decrypt, sign, verify, derive, wrap, unwrap. This specifies the operations that the generated key will be permitted to perform.
Return value
Type: Promise
A Promise object that will return a symmetric key (Key) or an asymmetric key pair (KeyPair) object that comprises both public and private keys.
Remarks
The generateKey method supports the following cryptographic algorithms:
- AES-CBC
- AES-GCM
- HMAC (SHA-1, SHA-256, SHA-384)
- RSAES-PKCS1-v1_5
- RSASSA-PKCS1-v1_5
- RSA-OAEP
For generateKey code examples, see the following topics:
See also
