Sign in to follow this  

how do I convert a byte buffer to a string?

This topic is 4228 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 );

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

This topic is 4228 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this