Nos bénévoles n'ont pas encore traduit cet article en Français. Aidez-nous à réaliser cette tâche !
The SubtleCrypto.exportKey()
method returns a Promise
of the key encrypted in the requested format. If the key is not extractable, that is if CryptoKey.extractable
returns false
, the promise fails with an InvalidAccessError
exception; it the format is unknown, the promive fails with a NotSupported
exception.
Syntax
var result = crypto.exportKey(format, key)
;
Parameters
format
is an enumerated value describing the data format in which the key has to be exported. 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"
, usually a public key, in the Simple public key infrastructure standard"jwk"
, the key in the JSON Web Key format.
key
is theCryptoKey
to export.
Return value
result
is aPromise
that returns the key in the requested format.
Exceptions
The promise is rejected when one of the following exceptions is encountered:
InvalidAccessError
when trying to export an non-extractable key.NotSupported
when trying to export in an unknown format.TypeError
when trying to use an invalid format.
Specifications
Specification | Status | Comment |
---|---|---|
Web Cryptography API The definition of 'SubtleCrypto.exportKey()' in that specification. |
Candidate Recommendation | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 37 | 34 (34) | Not supported | ? | Not supported |
ECDH |
? | 41 (41) | ? | ? | ? |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | 37 | 34.0 (34) | Not supported | ? | Not supported |
ECDH |
? | ? | 41.0 (41) | ? | ? | ? |
See also
Crypto
andCrypto.subtle
.SubtleCrypto
, the interface it belongs to.