Hello, I'm trying to do / learn how to use openssl MDC-2. I found an example ( link ) and I adapted to try to understand. This is functional for data entry via string (char). I need it to work for a data input type byte array.
Example: MDC-2 HASH = 000000000000000000000000000000000000AF626E45A45F8AE484DCDB3FF0FBC51B43976F4BFF93E741406CA34622955BE99F6C9C72A32D169423E3EB59D08AF31C2DC06FB16B5DC6BAF23AD4901EBEE6FE9FD145BC706CF43A9556C2B32F1BC5BDA3499B3132A386E14E91B391264B98303DDDA05F2F431D55CBD72235
MDC-2 Score = D247556FE71929C9761F128F7A604CA6
openssl / evp.h
int main () {
EVP_MD_CTX *mdctx;
const EVP_MD *md;
char mess[] = "The quick brown fox jumps over the lazy dog";
//char mess[] = "";
unsigned char md_value[EVP_MAX_MD_SIZE];
unsigned int md_len;
//OpenSSL_add_all_digests();
md = EVP_get_digestbyname("mdc2");
printf("\nOpenssl MDC-2 test\n\n");
printf("String Input....: %s\n\n",mess);
mdctx = EVP_MD_CTX_create();
EVP_DigestInit_ex(mdctx, md, NULL);
EVP_DigestUpdate(mdctx, mess, strlen(mess));
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
EVP_MD_CTX_destroy(mdctx);
printf("MDC-2 generated.: ");
for(int i = 0; i < md_len; i++)
printf("%02X", md_value[i]);
EVP_cleanup();
printf("\n\n\nD o n e !!!\n\n");
getchar();
return(0);
}
Sorry for the formatting.