Jump to content
  • Advertisement
Sign in to follow this  
etsuja

how do I convert a byte buffer to a string?

This topic is 4442 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
Advertisement
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
Quote:
Original post by etsuja
ascii


std::string foo(MyBuff, MyBuff+16); will do it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!