]> git.ardis.lu - static-encrypt/commitdiff
Add manual instructions to README
authorArdis Lu <ardisglu@gmail.com>
Thu, 23 Feb 2023 05:05:32 +0000 (21:05 -0800)
committerArdis Lu <ardisglu@gmail.com>
Thu, 23 Feb 2023 05:05:32 +0000 (21:05 -0800)
README.md

index bd92e41673f7c1296721649ca788acb0ca511804..a2766f39f55b464fff0299f1bdc8690194b3027c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,32 @@
 # static-encrypt
 
-A tool to make a password-protected frontend that can be hosted statically.
+A tool to encrypt any static content, and (optionally) create a basic password-protected frontend that can be hosted statically.
 
 Like [staticrypt](https://github.com/robinmoisson/staticrypt) but uses the modern [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) instead of `crypto-js`.
+
+## How to decrypt the encrypted content string manually
+
+1. Import the `decrypt` function provided in `/decrypt.js`:
+
+```javascript
+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:
+
+```javascript
+const plaintext = await decrypt('jklWIe958BY3LLgf/RDePN4ThOTUCPwBkEf9uueZRO2g2nVWuk20webn+/HR14b2iJJnYCkzDT05f7qhsnx4Of98uu+T5/oinZsQI3o3mhvPmfIwVAdl2tq1V8cG', 'hunter2');
+```
+
+3. The `decrypt` function will throw an error if the incorrect password is passed, or return the plaintext:
+
+```javascript
+plaintext
+// 'Hello, world!'
+```
+
+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');
+```
This page took 0.074377 seconds and 4 git commands to generate.