Tests and documentation for base64.

This commit is contained in:
EinMByte
2015-07-22 16:43:11 +02:00
parent 53053105c9
commit 28a4f4173d
5 changed files with 72 additions and 35 deletions

View File

@@ -45,23 +45,8 @@ namespace data
static char P64 = '=';
/*
*
* ByteStreamToBase64
* ------------------
*
* Converts binary encoded data to BASE64 format.
*
*/
size_t /* Number of bytes in the encoded buffer */
ByteStreamToBase64 (
const uint8_t * InBuffer, /* Input buffer, binary data */
size_t InCount, /* Number of bytes in the input buffer */
char * OutBuffer, /* output buffer */
size_t len /* length of output buffer */
)
size_t ByteStreamToBase64(const uint8_t* InBuffer, size_t InCount, char* OutBuffer, size_t len)
{
unsigned char * ps;
unsigned char * pd;
@@ -124,23 +109,8 @@ namespace data
return outCount;
}
/*
*
* Base64ToByteStream
* ------------------
*
* Converts BASE64 encoded data to binary format. If input buffer is
* not properly padded, buffer of negative length is returned
*
*/
size_t /* Number of output bytes */
Base64ToByteStream (
const char * InBuffer, /* BASE64 encoded buffer */
size_t InCount, /* Number of input bytes */
uint8_t * OutBuffer, /* output buffer length */
size_t len /* length of output buffer */
)
size_t Base64ToByteStream(const char * InBuffer, size_t InCount, uint8_t* OutBuffer, size_t len)
{
unsigned char * ps;
unsigned char * pd;
@@ -154,7 +124,7 @@ namespace data
if (isFirstTime) iT64Build();
n = InCount/4;
m = InCount%4;
if (!m)
if(InCount && !m)
outCount = 3*n;
else {
outCount = 0;