forked from ehn-dcc-development/base45-ansi-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
35 lines (29 loc) · 944 Bytes
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include "base45.h"
void check(char *in, char *out)
{
char enc[1024];
unsigned char dec[1024];
size_t elen = sizeof(enc), dlen = sizeof(dec);
bzero(enc, 1024);
bzero(dec, 1024);
assert(0 == base45_encode(enc, &elen, (const unsigned char *)in, strlen(in)));
assert(elen == strlen(out));
assert(0 == strcmp(enc, out));
assert(0 == base45_decode(dec, &dlen, out, strlen(out)));
assert(dlen == strlen(in));
assert(0 == bcmp(dec, in, dlen));
printf("base45(\"%s\") -> \"%s\"\n", (char *)dec, enc);
}
int main(int argc, char **argv)
{
check("Hello!!", "%69 VD92EX0");
check("base-45", "UJCLQE7W581");
check("ietf!", "QED8WEX0");
check("COVID-19", "-M8*+A%R81A6");
check("2021 Digital Green Certificates for travel",
"NF6OF6P34SED-EDAECS34ZKE1$CO345$CBWER.CGPC7WE.OEX.CBJEKWEKEC: C");
}