X-Git-Url: http://www.average.org/gitweb/?p=pam_pcsc_cr.git;a=blobdiff_plain;f=test_base64.c;fp=test_base64.c;h=83fbf57869cba2800031f88caee50b2787ae820b;hp=0000000000000000000000000000000000000000;hb=b4ed664ffb6e3f3764fa2b2f4b05437df43d7f19;hpb=b4bd8dfd5d7780bc00f820c3dec7b2a06f47b514 diff --git a/test_base64.c b/test_base64.c new file mode 100644 index 0000000..83fbf57 --- /dev/null +++ b/test_base64.c @@ -0,0 +1,55 @@ +/* +Copyright (c) 2013 Eugene Crosser + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation + would be appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include +#include +#include +#include "base64.h" + +static char src[40] = "Quick brown fox jumps over the lazy dog"; + +int main(int argc, char *argv[]) +{ + char b64[80]; + char dst[40]; + int bsize, dsize; + + printf("src=\"%s\" (%d)\n", src, (int)sizeof(src)); + bsize = sizeof(b64); + if (b64_encode(src, sizeof(src), b64, &bsize)) { + fprintf(stderr, "encode error\n"); + return 1; + } + printf("b64=\"%s\" (%d)\n", b64, bsize); + dsize = sizeof(dst); + if (b64_decode(b64, dst, &dsize)) { + fprintf(stderr, "decode error\n"); + return 1; + } + printf("dst=\"%s\" (%d)\n", dst, dsize); + return !(dsize == sizeof(src) && !memcmp(src, dst, dsize)); +}