#include "base85.h" using std::vector; // Functions modified from Dear ImGui and renamed to avoid collisions. static unsigned int DecodeBase85Byte(char c) { return c >= '\\' ? c-36 : c-35; } vector DecodeBase85(const char *src) { vector dst_vec; dst_vec.resize(((strlen(src) + 4) / 5) * 4); unsigned char *dst = dst_vec.data(); size_t dst_size = 0; while (*src) { unsigned int tmp = DecodeBase85Byte(src[0]) + 85 * (DecodeBase85Byte(src[1]) + 85 * (DecodeBase85Byte(src[2]) + 85 * (DecodeBase85Byte(src[3]) + 85 * DecodeBase85Byte(src[4])))); dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. src += 5; dst += 4; dst_size += 4; } dst_vec.resize(dst_size); return dst_vec; }