]> git.ardis.lu - static-encrypt/commitdiff
Drop default export
authorArdis Lu <ardisglu@gmail.com>
Sun, 23 Apr 2023 02:27:21 +0000 (19:27 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 23 Apr 2023 02:27:21 +0000 (19:27 -0700)
The syntax for dynamically importing default is annoying

README.md
decrypt.js
encrypt.js
index.html

index fac9eefa8d3ce816a06ed9be3e7645e876dec3d3..cb2167291bfbd404bfbe9dbb3c94fb59f8f82a6a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ To integrate the decryption into your own frontend:
 1. Import the `decrypt` function provided in `/decrypt.js`:
 
 ```javascript
-import decrypt from 'https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js';
+import { decrypt } from 'https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js';
 ```
 
 2. Pass the encrypted content string and the password to the `decrypt` function:
@@ -63,5 +63,5 @@ plaintext
 You can also import the function dynamically (useful for lazy-loading or testing in DevTools):
 
 ```javascript
-const { default: decrypt } = await import('https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js');
+const { decrypt } = await import('https://cdn.jsdelivr.net/gh/ardislu/static-encrypt/decrypt.js');
 ```
index ee4248b89d0bd1dc9955cca34f2e547f480ebaa0..a44f8f9003537ec95624b24ae74cf7e28c08f22a 100644 (file)
@@ -4,7 +4,7 @@
  * @param {string} password - The password used to encrypt the string.
  * @returns {Promise<string>} A promise that resolves to the plaintext.
  */
-export default async function decrypt(content, password) {
+export async function decrypt(content, password) {
   const encoder = new TextEncoder();
   const encodedPassword = encoder.encode(password);
   const additionalData = encoder.encode('https://github.com/ardislu/static-encrypt');
index e53edc865658c2f54405a4c9d0f043a46b9f4181..f86eceaf10ff2251f6603f8fc365d980e1352d04 100644 (file)
@@ -4,7 +4,7 @@
  * @param {string} password - The password used to encrypt the string.
  * @returns {Promise<string>} A promise that resolves to the ciphertext.
  */
-export default async function encrypt(plaintext, password) {
+export async function encrypt(plaintext, password) {
   const encoder = new TextEncoder();
   const encodedPlaintext = encoder.encode(plaintext);
   const encodedPassword = encoder.encode(password);
index 051e4a82f129a7df411aea0538c5704ccb370942..a999a2d2bd4500088f3cb2920a4d4ad2f94c7093 100644 (file)
   </footer>
 
   <script type="module">
-    import encrypt from '/encrypt.js';
-    import decrypt from '/decrypt.js';
+    import { encrypt } from '/encrypt.js';
+    import { decrypt } from '/decrypt.js';
 
     function setOutput(ciphertext) {
       document.querySelector('#output').style.display = 'block';
This page took 0.042727 seconds and 4 git commands to generate.