#include #include #include "hasher.h" #include "log.h" #define BUFLEN 2048 int main(void){ log("hi\n"); if(init_hasher()){ log("Error encountered while initializing hasher"); } unsigned char * in = (unsigned char*)malloc(sizeof(unsigned char) * BUFLEN); size_t inlen = 0; char * signin = (char*)malloc(sizeof(char) * BUFLEN); ssize_t bytesread = getline(&signin, &inlen, stdin); memcpy(in, signin, bytesread); printf("Input:\n\t"); for(int i = 0; i < bytesread; i++){ printf("%02x ", in[i]); } printf("\n\t"); for(int i = 0; i < bytesread; i++){ printf(" %c ", in[i]); } printf("\n"); unsigned int len; unsigned char * a = digest(in, bytesread, &len); char * aa = (char*)malloc(sizeof(char) * 2 * len); printf("Output:\n\t"); for(int i = 0; i < len; i++){ sprintf(aa + (2 * i), "%02x", a[i]); } printf("%s\n", aa); OPENSSL_free(a); free(aa); if(deinit_hasher()){ log("Error encountered while deinitializing hasher"); } return 0; }