This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib as hasher | |
import datetime as date | |
class Block: | |
def __init__(self, index, timestamp, data, previous_hash): | |
self.index = index | |
self.timestamp = timestamp | |
self.data = data | |
self.previous_hash = previous_hash | |
self.hash = self.hash_block() | |
def hash_block(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]) { | |
FILE *fp; | |
if (argc != 2 || | |
(fp = fopen(argv[1], "r")) == NULL) { | |
perror("File opening failed"); | |
return EXIT_FAILURE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int get_utf8_size(const unsigned char *p_input) { | |
unsigned char c = *p_input; /* get UTF-8 first Byte */ | |
/* | |
* 0xxxxxxx --> 1 | |
* 10xxxxxx --> -1 (invalid) | |
* 110xxxxx --> 2 | |
* 1110xxxx --> 3 | |
* 11110xxx --> 4 | |
* 111110xx --> 5 |