MD5:
what is MD5:
MD5 message-digest algorithm with hash value of 16 bytes(128 bit).
RFC link: http://tools.ietf.org/html/rfc1321
Designed by : R. Rivest
Calculation MD5 for a string.
#include <stdio.h>
#include <string.h>
#include "openssl/md5.h"
#pragma comment(lib,"libeay32.lib")
#pragma comment(lib,"ssleay32.lib")
// 16 bytes = 16 * 8 ( 128 bits)
#define PRINT_HASH 33
int main()
{
unsigned char digest[MD5_DIGEST_LENGTH];
char string[] = "blogger";
MD5((unsigned char*)&string, strlen(string), (unsigned char*)&digest);
printf("the function prints %s \t unreadable value\n",digest);
char convertedString[PRINT_HASH];
printf("prints hash value in unsigned decimal\n");
for(int i = 0; i < MD5_DIGEST_LENGTH; i++)
printf("%u ",(unsigned int)digest[i]);
printf("\n");
printf(" Hexa Demical 16 byte hash value for string %s is : ",string);
for (int i = 0; i < 16; i++)
printf ("%02x", digest[i]);
return 0;
}
No comments:
Post a Comment