Brian Dantes brian@things.org writes:
From a quick glance at the code, it appears that it is not safe to use the same buffer for dst and src when calling base64_encode_update. Is this correct?
It's correct that it's not safe. The basic reason is that base64 expands the data. If one used the same buffer for input and output, the output would overwrite input data before it is processed.
If one is careful, one can use base64_encode_raw for in place operation. This function encodes the data starting from the end.
It would be nice to somehow extend this property to base64_encode_update, but it's sligthly more hairy due to the bits left over between calls to base64_encode_update.
Regards, /Niels