BASE64 toolkit

A toolkit to encode/decode BASE64 data.

Free to use, I’d just like a copy of the result and please give some credit.

©2006 Marcel Kilgus

B64_ENCODE

Syntax: output_size = B64_ENCODE(source_addr, length, dest_addr)

Encode the text at the given source address into BASE64. Writes result to the destination address and returns the length of the data written. By not using strings the data is not limited by the 32kb string limit.

The given destination buffer must be big enough for the encoded data. By reserving “length * 1.5” bytes one is on the safe side.

B64_DECODE

Syntax: output_size = B64_DECODE(source_addr, length, dest_addr)

Decode the given BASE64 data, pointed to by source_addr, into the memory located at dest_addr. Returns the size of the decoded data in bytes. By not using strings the data is not limited by the 32kb string limit.

The given destination buffer must be big enough for the decoded data. Decoded data is always smaller than encoded data.

Example

Encodes and decodes the Wikipedia moto.