Guest User

Untitled

a guest
Oct 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3.  
  4. unsigned char* to_string(struct block b)
  5. {
  6. unsigned char *str=malloc(sizeof(unsigned char)*sizeof(b));
  7. memcpy(str,&b,sizeof(b));
  8. return str;
  9. }
  10.  
  11. void print_hash(unsigned char hash[], int length)
  12. {
  13. for(int i=0; i<length; i++)
  14. printf("%02x",hash[i]);
  15. }
  16.  
  17. int compare_hash(unsigned char *hash1, unsigned char *hash2)
  18. {
  19. for(int i=0; i<SHA256_DIGEST_LENGTH; i++)
  20. if(hash1[i]!=hash2[i])
  21. return FALSE;
  22. return TRUE;
  23. }
  24.  
  25. void print_block(struct block *b)
  26. {
  27. printf("%p\t",b);
  28. print_hash(b->prev_hash,sizeof(b->prev_hash));
  29. printf("\t[%d]\t",b->block_data);
  30. printf("\n");
  31. }
Add Comment
Please, Sign In to add comment