To try it out, check the demo page:
Or download the two files crypto.html and crypto.js to your computer, no web-server is needed as these functions are directly interpreted in all modern browsers.
crypted-data is a container that contains encrypted data:
- "algorithm" is not needed at the moment, because only AES-GCM is implemented yet
- "group" combines a group of elements that can be decrypted with the same password at the same time
- "salt" is the salt (base64url encoded) used when the data was encrypted
- "content" the encrypted data (base64url encoded)
<crypted-data algorithm="AES-GCM" group="0" salt="dTe2oVxNnG4btg"> aINh0EZxbLlD9wXdCVqlJYojCsDAL6fhzUpJ8LrPVQ </crypted-data>
Clicking on the unlock button opens an input window to enter the password for decryption.
After entering the correct password, all crypted-data elements of the corresponding group are decrypted and displayed.
When the lock button is clicked, all crypted-data elements of the group are hidden.
crypted-encoder is an element which can be included on an html-page to encrypt data:
<crypted-encoder></crypted-encoder>
Example:
After entering a password, a salt is generated and the content is encrypted. The salt and the encrypted data are base64url encoded and can then be used in a crypted-data element.
License BSD-3-Clause
Copyright (C) 2021 Alexander Schoepe, Bochum, DE
See also:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements