From: Ardis Lu Date: Sun, 23 Apr 2023 02:27:21 +0000 (-0700) Subject: Drop default export X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=927d31a143a4d85f09712ce0b6ead947a9503347;p=static-encrypt Drop default export The syntax for dynamically importing default is annoying --- diff --git a/README.md b/README.md index fac9eef..cb21672 100644 --- 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'); ``` diff --git a/decrypt.js b/decrypt.js index ee4248b..a44f8f9 100644 --- a/decrypt.js +++ b/decrypt.js @@ -4,7 +4,7 @@ * @param {string} password - The password used to encrypt the string. * @returns {Promise} 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'); diff --git a/encrypt.js b/encrypt.js index e53edc8..f86ecea 100644 --- a/encrypt.js +++ b/encrypt.js @@ -4,7 +4,7 @@ * @param {string} password - The password used to encrypt the string. * @returns {Promise} 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); diff --git a/index.html b/index.html index 051e4a8..a999a2d 100644 --- a/index.html +++ b/index.html @@ -173,8 +173,8 @@