/** * \file modp_b85.h * \brief Base 85 encoding and decoding * * This provides a endian-safe base85 encode/decode operations. This * means, the result will be the same on x86 or ibm/sparc chips. */ /* *
* High Performance Base85 Encoder / Decoder * * Copyright © 2006-2016 Nick Galbreath -- nickg [at] client9 [dot] com * All rights reserved. * * https://github.com/client9/stringencoders/ * * Released under MIT license. See LICENSE for details. ** * This provides a endian-safe base85 encode/decode operations. This * means, the result will be the same on x86 or ibm/sparc chips. * * (Note: making it endian-specifc only results in a 5% savings in * the decode operation, so why bother) */ #ifndef COM_MODP_STRINGENCODERS_B85 #define COM_MODP_STRINGENCODERS_B85 #include "extern_c_begin.h" #include "modp_stdint.h" /** * \brief base 85 encode * * \param[out] dest should have at least b85fast_encode_len memory allocated * \param[in] src input string * \param[in] len input string length, must be a multiple of 4 * \return the strlen of the destination, or -1 if error * */ size_t modp_b85_encode(char* dest, const char* src, size_t len); /** * \brief Base 85 decode * \param[out] dest -- destination locations. May equal input. * \param[in] src -- source b85data * \param len -- length of source * \return -1 on decoding error, length of output otherwise * No ending null is added */ size_t modp_b85_decode(char* dest, const char* src, size_t len); /** * \brief Returns the amount of memory to allocate for encoding the input * string. * */ #define modp_b85_encode_len(A) ((A + 3) / 4 * 5 + 1) /** * \brief Return output strlen, without a NULL */ #define modp_b85_encode_strlen(A) ((A + 3) / 4 * 5) /** * \brief Return the amount of memory to allocate for decoding a base 85 * encoded string. * */ #define modp_b85_decode_len(A) ((A + 4) / 5 * 4) #include "extern_c_end.h" #ifdef __cplusplus #include