var result = crypto
.subtle.importKey(format, keyData, algo, extractable, usages);
formatis an enumerated value describing the data format of the key to imported. It can be one of the following:
"raw", the key as an array of bytes, usually a secret key.
"pkcs8"a private key, in the IETF Public Key-Cryptographic Standard Encryption #8.
"spki", a public key in DER encoding of the SubjectPublicKeyInfo structure from RFC 5280.
"jwk", the key in the JSON Web Key format.
JSONWebKeycontaining the key in the given format.
algois a dictionary object defining the algorithm that was used to generate the key being imported.
Booleanindicating if the key can be extracted from the
CryptoKeyobject at a later stage.
Arrayindicating what can be done with the key. Possible values of the array are:
"encrypt", allowing the key to be used for encrypting messages.
"decrypt", allowing the key to be used for decrypting messages.
"sign", allowing the key to be used for signing messages.
"verify", allowing the key to be used for verifying the signature of messages.
"deriveKey", allowing the key to be used as a base key when deriving a new key.
"deriveBits", allowing the key to be used as a base key when deriving bits of data for use in cryptographic primitives.
"wrapKey", allowing the key to wrap a symmetric key for usage (transfer, storage) in unsecure environments.
"unwrapKey", allowing the key to unwrap a symmetric key for usage (transfer, storage) in unsecure environments.
The promise is rejected when one of the following exceptions is encountered:
keyUsagesis empty but the unwrapped key is of type
TypeErrorwhen trying to use an invalid format or if the
keyDatais not suited for that format.
|Web Cryptography API
The definition of 'SubtleCrypto.importKey()' in that specification.
|Feature||Android webview||Chrome for Android||Edge mobile||Firefox for Android||Opera Android||iOS Safari||Samsung Internet|
32 — 341
1. From version 32 until version 34 (exclusive): this feature is behind the
dom.webcrypto.enabled preference (needs to be set to
true). To change preferences in Firefox, visit about:config.
KeyOperation instead of