> - Store data in flat text files.
Storing encryption keys or the like in flat text files is surprisingly hard, at least in C. I don't think it's even possible to use sscanf(3) without unexpected explosions, and otherwise you get to hand-roll your hex parsing code yourself (Base 64? Get yourself a library).
Working with that sort of file in C is trivial, you either open() and read() from that file, or mmap() it.
Storing keys (or other binary) data is _exceptionally_ easy with C. What's hard is _multiplexing_ it with other data in the same file, but you probably don't need to:
some.config:
keyfile=/some/path/to/just/the/key
But yes, C is very weak on converting data from one encoding into another. You end-up always having to write your own encoder/decoder.
You should be able to convert between binary and base64 on memory more easily than during IO, and for encryption keys the buffers all have known size limits. As a rule sscanf will add security vulnerabilities to your code, so one should better avoid it if you do not trust your inputs.
- Small is beautiful.
- Make each program do one thing well.
- Build a prototype as soon as possible.
- Choose portability over efficiency.
- Store data in flat text files.
- Use software leverage to your advantage.
- Use shell scripts to increase leverage and portability.
- Avoid captive user interfaces.
- Make every program a filter.