Applies to: desktop apps only
The CryptBinaryToString function converts an array of bytes into a formatted string.
BOOL WINAPI CryptBinaryToString( __in const BYTE *pbBinary, __in DWORD cbBinary, __in DWORD dwFlags, __out_opt LPTSTR pszString, __inout DWORD *pcchString );
A pointer to the array of bytes to be converted into a string.
The number of elements in the pbBinary array.
Specifies the format of the resulting formatted string. This parameter can be one of the following values.
Base64, with certificate beginning and ending headers.
Base64, without headers.
Pure binary copy.
Base64, with request beginning and ending headers.
Hexadecimal only.
Hexadecimal, with ASCII character display.
Base64, with X.509 CRL beginning and ending headers.
Hexadecimal, with address display.
Hexadecimal, with ASCII character and address display.
A raw hexadecimal string.
Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
Enforce strict decoding of ASN.1 text formats. Some ASN.1 binary BLOBS can may have the first few bytes of the BLOB incorrectly interpreted as Base64 text. In this case, the rest of the text is ignored. Use this flag to enforce complete decoding of the BLOB.
Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, and Windows 2000: This value is not supported.
In addition to the values above, one or more of the following values can be specified to modify the behavior of the function.
Do not append any new line characters to the encoded string. The default behavior is to use a carriage return/line feed (CR/LF) pair (0x0D/0x0A) to represent a new line.
Windows Server 2003 and Windows XP: This value is not supported.
Only use the line feed (LF) character (0x0A) for a new line. The default behavior is to use a CR/LF pair (0x0D/0x0A) to represent a new line.
A pointer to a buffer that receives the converted string. To calculate the number of characters that must be allocated to hold the returned string, set this parameter to NULL. The function will place the required number of characters, including the terminating NULL character, in the value pointed to by pcchString.
A pointer to a DWORD variable that contains the size, in TCHARs, of the pszString buffer. If pszString is NULL, the function calculates the length of the return string (including the terminating null character) in TCHARs and returns it in this parameter. If pszString is not NULL and big enough, the function converts the binary data into a specified string format including the terminating null character, but pcchString receives the length in TCHARs, not including the terminating null character.
If the function succeeds, the function returns nonzero (TRUE).
If the function fails, it returns zero (FALSE).
With the exception of when CRYPT_STRING_BINARY encoding is used, all strings are appended with a new line sequence. By default, the new line sequence is a CR/LF pair (0x0D/0x0A). If the dwFlags parameter contains the CRYPT_STRING_NOCR flag, then the new line sequence is a LF character (0x0A). If the dwFlags parameter contains the CRYPT_STRING_NOCRLF flag, then no new line sequence is appended to the string.
Minimum supported client
Minimum supported server
Header
Library
DLL
Unicode and ANSI names
Send comments about this topic to Microsoft
Build date: 3/6/2012