Web Crypto: importKey
This page shows the use of the
importKey() function of the Web Crypto API. It contains four separate examples, one for each import format supported:
- PKCS #8
- JSON Web Key
Each example has the same structure: you get a message a button labeled "Import Key".
If you click "Import Key" then the example imports a particular key:
- For "Raw", an AES encryption key.
- For "PKCS #8", an RSA private signing key.
- For "SubjectPublicKeyInfo", an RSA public encryption key.
- For "JSON Web Key", an EC private signing key.
A new button is then displayed, labeled "Sign" or "Encrypt", depending on the key that was imported. You can click it to use the imported key to perform the appropriate operation and display the result.