Encrypting Static Site Content with WASM
April 2026
Overview
The page encrypts files so they can be password protected on static sites without additional server side processes. It's the counterpart to Password Protecting Static Site Content with WASM. Check out that page for details on the combination.
The Encryptor
Wrap Up
I use this page to encrypt single files. I use a command line version (e.g. from Encrypt a File with a Password in Rust) when I'm working on batches of files.
The source code is below. I was pleasantly surprised by how little it took to get things running. Of course, the Rust library that's doing all the heavy lifting is way more complicated.
Very cool.
-a
The Source Code
Rust Code
src/lib.rs
use ;
use *;
Cargo.toml
name = "static-site-file-encryption"
version = "0.1.0"
edition = "2024"
crate-type =
getrandom =
orion = "0.17.13"
wasm-bindgen = "0.2.117"Rust Build Script
built-release.bash
#!/bin/bash
[ &&
[ && Web Page Code
HTML
File To Encrypt:
Password to use:
JavaScript
References
- https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
- https://doc.libsodium.org/password_hashing/default_phf#guidelines-for-choosing-the-parameters
- https://docs.rs/orion/latest/orion/
- https://docs.rs/orion/latest/orion/aead/index.html
- https://docs.rs/orion/latest/orion/kdf/index.html
- https://docs.rs/orion/latest/orion/kdf/struct.Salt.html
- https://docs.rs/wasm-bindgen/latest/wasm_bindgen/