/* kmd5.c * MD5 と BASE64 の例 * MD5: apr_md5 * BASE64: apr_base64_encode / apr_base64_encode_len */ #define USAGE "Usage: kmd5.exe \n" #include "apr_general.h" #include "apr_file_io.h" #include "apr_errno.h" #include "apr_md5.h" #include "apr_base64.h" #include "mystab.h" #define ERROR_BUF_SIZE 1024 int apr_my_main (int ac, char **av, apr_file_t * astdin, apr_file_t * astdout, apr_file_t * astderr, apr_pool_t * pool) { char error_buf[ERROR_BUF_SIZE]; apr_status_t statcode; unsigned char *data; unsigned char *encodedData; if (ac < 2) { apr_file_printf(astderr, USAGE); goto _ERROR_; } /* * INCLUDE: apr_md5.h * LIBS: libapr-1.lib libaprutil-1.lib */ { unsigned char digest[APR_MD5_DIGESTSIZE]; char *input = av[1]; apr_size_t inputLen = strlen(input); if (APR_SUCCESS != (statcode = apr_md5(digest, input, inputLen))) { apr_file_printf(astderr, "ERROR: apr_md5: %s\n", apr_strerror(statcode, error_buf, ERROR_BUF_SIZE)); goto _ERROR_; } { int i; apr_file_printf(astdout, "HEX DUMP: ["); for (i=0; i