From: Ardis Lu Date: Thu, 23 Feb 2023 05:05:32 +0000 (-0800) Subject: Add manual instructions to README X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=a667d65540a53f86c36b34dec6a1a8330e8be616;p=static-encrypt Add manual instructions to README --- diff --git a/README.md b/README.md index bd92e41..a2766f3 100644 --- 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'); +```