int base32decode(
const char * encoded,
unsigned char * decodedBytes,
size_t maxbuf
);
encoded \0 terminated char buffer with encoded string
decodedBytes outputbuffer (or NULL)
maxbuff size of the output buffer
returns the decoded byte array in decodedBytes and the length. Or if decodedBytes==NULL, will just return the length needed; regardless of the value of maxbuff.
If the size of maxbuff allows it - a terminating \0 is added (but not including in the length returned) - as very often the decoded data itself is actually again a string.
int base32decodeToString(String encoded, String &decoded);
encoded String with the encoded base32 value
&decoded returned string (if any)
Will return the length of the decoded string or a negative value on error.
Typical use:
String in = "IFZGI5LJNZXSAUTVNRSXU===";
String out;
int r = base32decodeToString(in, out);
if (r < 0) {
Serial.println("Could not decode the string");
return;
};
Serial.print("Decoded: ");
Serial.println(out);