robinmoisson /staticrypt
Password protect a static HTML page, decrypted in-browser in JS with no dependency. No server logic needed.
★ 8,073⑂ 501
8,073
stars
+7+8+21
501
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions
README
live example StatiCrypt Safely encrypt and password protect the content of your _public_ static HTML file, to be decrypted in-browser without any back-end - to serve it over static hosting like Netlify, GitHub pages, etc. (see a live example). StatiCrypt uses AES-256 and WebCrypto to encrypt your HTML file with your long password, and returns a static HTML page showing a password prompt that you can now safely upload anywhere, the page containing your encrypted content and decryption happening in javascript client side (see the details of how it works). 👉️ You can encrypt a file online in your browser (client side) at robinmoisson.github.io/staticrypt, or use the CLI to do it in your terminal or build process. 🌱 Supporting: If you want to support StatiCrypt development you can do so by clicking on the sponsor button (you can also come study meditation with me, or use my other tool to translate books). See how donations are used. Thank you for your support! CLI Migration: v3 brings many improvements, a clearer CLI and simpler password_template over v2. See the migration guide from v2 to v3. v3 uses WebCrypto which is only available in HTTPS or localhost contexts, so if you need to use it in HTTP you'll need to use v2. Installation Staticrypt is available through npm as a CLI, install with bash npm install staticrypt You can then run it with npx staticrypt .... You can also install globally with npm install -g staticrypt and then just call staticrypt ... from anywhere. Examples These examples will create a .staticrypt.json file in the current directory (here's why). This file isn't secret and you don't need to protect it. You can prevent this by setting the --config flag to false (a string). Encrypt a file Encrypt test.html and create a encrypted/test.html file (use -d my_directory to change the output directory): bash this will prompt you for the password, which won't stay in your terminal command history staticrypt test.html you can also pass the password as an argument staticrypt test.html -p Encrypt a file with the password in an environment variable Set your long password in the STATICRYPT_PASSWORD environment variable (.env files are supported): bash the password is in the STATICRYPT_PASSWORD env variable, you won't be prompted staticrypt test.html Encrypt multiple HTML files at once This will put the HTML files in an encrypted directory, created where you run the staticrypt command. Non-HTML files will be copied as-is from the input directory, so you can easily overwrite it with the encrypted directory if you want. bash this will encrypt test_A.html and test_B.html staticrypt test_A.html test_B.html = encrypted files are in encrypted/test_A.html and encrypted/test_B.html you can also use the -r flag to recursively encrypt all files in a directory staticrypt dir_to_encrypt -r = encrypted files are in encrypted/dir_to_encrypt/... if you don't want to include the directory name in the output path