I'm working on MIME message generation code and I'd like to generate as small boundaries as possible for any given input even of unknown length in stream mode.
Right now I end up with good enough solution which based on random generator. Basically I generate random string of 32 Base64 symbols and try to find shortest substring in it which is not substring of MIME message body.
This is not perfect solution because:
The boundary is not always shortest. For very simplified example: for alpha-only text the boundary could be just one digit, but generated boundary material could contain only alphas.
I need random generator and unique seed for it each time I run the application. Ideally better to have deterministic algorithm.
So that's what I want to know. It's possible to keep the property of streaming algorithm, work on fixed amount of memory, be deterministic and generate ideal shortest boundary? Or we can achieve only some of properties by tradeoffs?