Commit 32238fe7 authored by Davide Galassi's avatar Davide Galassi

Base64 API revision

Inverted source/destination parameter
parent f20437ed
Pipeline #34193557 passed with stages
in 1 minute and 21 seconds
......@@ -12,9 +12,9 @@ extern "C"{
#include <stddef.h>
size_t cry_base64_encode(const char *in, size_t len, char *out);
size_t cry_base64_encode(char *out, const char *in, size_t len);
size_t cry_base64_decode(const char *in, size_t len, char *out);
size_t cry_base64_decode(char *out, const char *in, size_t len);
#ifdef __cplusplus
}
......
......@@ -3,7 +3,7 @@
static const char *base64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
size_t cry_base64_encode(const char *in, size_t len, char *out)
size_t cry_base64_encode(char *out, const char *in, size_t len)
{
size_t i, outlen = 0;
......@@ -59,7 +59,7 @@ static const unsigned char unbase64[] = {
49, 50, 51, 255, 255, 255, 255, 255,
};
size_t cry_base64_decode(const char *in, size_t len, char *out)
size_t cry_base64_decode(char *out, const char *in, size_t len)
{
size_t i, outlen = 0;
......
......@@ -9,7 +9,7 @@ static void encode(int argc, char *argv[])
ASSERT(argc == 3);
len = atoi(argv[2]);
ASSERT(cry_base64_encode(argv[0], strlen(argv[0]), (char *)g_buf) == len);
ASSERT(cry_base64_encode((char *)g_buf, argv[0], strlen(argv[0])) == len);
if (len >= 0)
ASSERT_EQ_BUF(g_buf, argv[1], len);
}
......@@ -21,7 +21,7 @@ static void decode(int argc, char *argv[])
ASSERT(argc == 3);
len = atoi(argv[2]);
ASSERT(cry_base64_decode(argv[0], strlen(argv[0]), (char *)g_buf) == len);
ASSERT(cry_base64_decode((char *)g_buf, argv[0], strlen(argv[0])) == len);
if (len >= 0)
ASSERT_EQ_BUF(g_buf, argv[1], len);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment