Split a File into Multiple Collections of Bytes
This started as an idea for how to split up files so they don't get ingested by scrapper bots. It turns one file into two with every other byte going to the alternate file from the one before it. These can then be reassembled in WASM on the front-end.
Then, I realized I could just encrypt the files. They could be decoded automatically by simply including the password in the javascript on the page. Or, you could set up a form so that only folks with the password could get them.
I really like that idea in general. Basically, a way to serve encrypted content on a static site. I built a prototype of that here: Password Protecting Static Site Content with WASM.
In the mean time, here's the code that does the split.
use Result;
use fs;
use Path;
use PathBuf;
name = "unzip_a_file"
version = "0.1.0"
edition = "2024"
anyhow = "1.0.102"I haven't written the re-assembly code yet since I'm going with encryption. I don't expect it to be difficult if I come back to it.
-a