Encoding Base64 with this library inevitably results in hangs/crashes/etc. This is not allocating enough space for the null terminator, you need to add one, like the original php code did. https://github.com/mikeho/QSUtilities/blob/master/QSStrings.m#L159