machdyne / blaustahl

Blaustahl Storage Device
Other
35 stars 6 forks source link

Encryption, compression, and Base64 encoding #4

Open akrabu opened 1 week ago

akrabu commented 1 week ago

This isn't really a feature request. It's more of a tutorial / possible inspiration for whoever comes across it. Wasn't sure where else to put it.

As an experiment to see how much data I could cram onto my Blaustahl, along with encryption... I put everything I wanted into a text file, saved it as "pw.txt", then ran...

brotli pw.txt
openssl enc -aes-256-cbc -salt -in pw.txt -out pw.txt.aes
base64 -b 80 -i pw.txt.aes -o pw.txt.aes.b64

The result was compressed, encrypted, and Base64 encoded... resulting in 2,564 bytes stored in 1,587 bytes.

Then I opened the .b64 file up with a text editor, opened the Blaustahl interface via Screen, switched on write mode, ensured the cursor was at the very beginning, then copied and pasted 24 rows at a time, pasting into the Blaustahl interface. It worked like a charm! (Note: the status bar may get in your way - if you can't hide it, you might try pasting 23 rows at a time instead and leaving the status bar line blank)

For the fun of it, I then copied it all back out a page at a time, ran the process in reverse, and there was all my data. :)

Now it would be cool if this was all built in somehow - but even if it isn't, doing it manually isn't too hard. I wouldn't want to do much more than 8KB, though haha

machdyne commented 5 days ago

Nice. I plan to add support for xmodem or something similar which might be easier than copy/paste, but it's great that works. A line wrap mode might make that work better. It's also possible to use the 'bs' utility to transfer the data, and access all 8192 bytes of FRAM. The editor interface only provides access to 7680 (80 24 4) bytes, reserving 512 for encryption support.

akrabu commented 5 days ago

Oh xmodem support would be nifty. And line wrap would be super useful, especially if it continued through multiple pages.

I've tried the bs utility but couldn't get it to work. I may fiddle with it again sometime.

akrabu commented 5 days ago

Hmm... is it possible to write binary data directly to the FRAM? I could store even more if I didn't need the Base64 encoding.

machdyne commented 5 days ago

You can read/write raw binary data directly to the FRAM with bs, but it may cause issues when using the editor afterwards. If it does, I would consider that a bug. It might be interesting to add a hex editor mode.