Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdlib.h>
- unsigned char* to_string(struct block b)
- {
- unsigned char *str=malloc(sizeof(unsigned char)*sizeof(b));
- memcpy(str,&b,sizeof(b));
- return str;
- }
- void print_hash(unsigned char hash[], int length)
- {
- for(int i=0; i<length; i++)
- printf("%02x",hash[i]);
- }
- int compare_hash(unsigned char *hash1, unsigned char *hash2)
- {
- for(int i=0; i<SHA256_DIGEST_LENGTH; i++)
- if(hash1[i]!=hash2[i])
- return FALSE;
- return TRUE;
- }
- void print_block(struct block *b)
- {
- printf("%p\t",b);
- print_hash(b->prev_hash,sizeof(b->prev_hash));
- printf("\t[%d]\t",b->block_data);
- printf("\n");
- }
Add Comment
Please, Sign In to add comment