Ipquarx

Untitled

Dec 27th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. char* tostring(uint8_t* in, int32_t inlength)
  2. {
  3.     char hex[] = "0123456789ABCDEF";
  4.     char* str = (char*)malloc(inlength + 2);
  5.  
  6.     inlength <<= 1;
  7.     for(int32_t a = 0; a < inlength; a += 2)
  8.     {
  9.         str[a]   = hex[(in[a>>1] & 0xf0) >> 4];
  10.         str[a+1] = hex[in[a>>1] & 0x0f];
  11.     }
  12.     inlength >>= 1;
  13.     str[inlength] = 0;
  14.     str[inlength + 1] = 0;
  15.  
  16.     return str;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment