fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void)
  5. {
  6. unsigned char hex[] = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
  7.  
  8. size_t stringLength = (sizeof(hex)/sizeof(hex[0]))-1;
  9.  
  10. unsigned char tmpInHash[stringLength/2];
  11.  
  12. int j=0;
  13.  
  14. tmpInHash[0] = 0;
  15.  
  16. for (size_t i = 0; i < stringLength; i++)
  17. {
  18. if ((hex[i] >= 'a') && (hex[i] <= 'z'))
  19. {
  20. tmpInHash[j] |= hex[i] -'a' + 10;
  21. }
  22. else if ((hex[i] >= '0') && (hex[i] <= '9'))
  23. {
  24. tmpInHash[j] |= hex[i] -'0';
  25. }
  26.  
  27. if ((i%2) == 0)
  28. {
  29. tmpInHash[j]<<=4;
  30. }
  31. else
  32. {
  33. j++;
  34.  
  35. if (j < stringLength/2)
  36. tmpInHash[j] = 0;
  37. }
  38.  
  39. }
  40.  
  41. for (size_t i = 0; i < stringLength/2; i++)
  42. {
  43. printf("0x%02X ", tmpInHash[i]);
  44. }
  45.  
  46. printf("\n");
  47.  
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
0x9F 0x86 0xD0 0x81 0x88 0x4C 0x7D 0x65 0x9A 0x2F 0xEA 0xA0 0xC5 0x5A 0xD0 0x15 0xA3 0xBF 0x4F 0x1B 0x2B 0x0B 0x82 0x2C 0xD1 0x5D 0x6C 0x15 0xB0 0xF0 0x0A 0x08