diff --git a/misc.c b/misc.c index df814bb..a3e1639 100644 --- a/misc.c +++ b/misc.c @@ -44,6 +44,7 @@ BOOL Base64Encode(const char *input, int input_len, char **output) { DWORD output_len; + DWORD flags = CRYPT_STRING_BASE64|CRYPT_STRING_NOCRLF; if (input_len == 0) { @@ -52,7 +53,7 @@ Base64Encode(const char *input, int input_len, char **output) return TRUE; } if (!CryptBinaryToStringA((const BYTE *) input, (DWORD) input_len, - CRYPT_STRING_BASE64, NULL, &output_len) || output_len == 0) + flags, NULL, &output_len) || output_len == 0) { #ifdef DEBUG PrintDebug (L"Error in CryptBinaryToStringA: input = '%.*S'", input_len, input); @@ -65,7 +66,7 @@ Base64Encode(const char *input, int input_len, char **output) return FALSE; if (!CryptBinaryToStringA((const BYTE *) input, (DWORD) input_len, - CRYPT_STRING_BASE64, *output, &output_len)) + flags, *output, &output_len)) { #ifdef DEBUG PrintDebug (L"Error in CryptBinaryToStringA: input = '%.*S'", input_len, input); @@ -74,12 +75,6 @@ Base64Encode(const char *input, int input_len, char **output) *output = NULL; return FALSE; } - /* Trim trailing "\r\n" manually. - Actually they can be stripped by adding CRYPT_STRING_NOCRLF to dwFlags, - but Windows XP/2003 does not support this flag. */ - if(output_len > 1 && (*output)[output_len - 1] == '\x0A' - && (*output)[output_len - 2] == '\x0D') - (*output)[output_len - 2] = 0; return TRUE; }