how do I convert a byte buffer to a string?
is there a function I can use to do this or do I have to write my own? I'm trying to use convert the number generated by CrypGenRandom() to a string.
Let me know id I'm doing the CrypGenRandom() part right...
BYTE MyBuff[16];
CryptGenRandom(hCryptProv,16,MyBuff);
here's the prototype for the function:
BOOL WINAPI CryptGenRandom(
HCRYPTPROV hProv,
DWORD dwLen,
BYTE* pbBuffer
);
Do you want the string to be the decimal representation of the binary number in the buffer, or to be the ascii interpretation of the data in the buffer?
What base do you want the number in? If you want base 2, 8, or 16 it's easy. If you want a 16-byte base 10 integer as a string... which is what I'm betting that you are looking for you have two choices:
1) download a bignum library (GNU gmp, OpenSSL, etc.)
or
2) write your own, which can be a neat exercise.
1) download a bignum library (GNU gmp, OpenSSL, etc.)
or
2) write your own, which can be a neat exercise.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement