Complete sources for a monero webminer.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
838 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include <stdint.h>
  7. #include "slow-hash.h"
  8. char *hash_cn(char *hex, int light, int variant)
  9. {
  10. char *output = (char *)malloc((64 + 1) * sizeof(char));
  11. int len = strlen(hex) / 2;
  12. unsigned char val[len], *pos = hex;
  13. for (size_t count = 0; count < len; count++)
  14. {
  15. sscanf(pos, "%2hhx", &val[count]);
  16. pos += 2;
  17. }
  18. if (variant == -1)
  19. variant = ((const uint8_t *)val)[0] >= 7 ? ((const uint8_t *)val)[0] - 6 : 0;
  20. unsigned char hash[32];
  21. cn_slow_hash(&val, len, &hash, light, variant, 0);
  22. char *ptr = &output[0];
  23. for (size_t i = 0; i < 32; i++)
  24. {
  25. ptr += sprintf(ptr, "%02x", hash[i]);
  26. }
  27. return &output[0];
  28. }
  29. void hash_free(void *ptr)
  30. {
  31. free(ptr);
  32. }