blob: eb82e1b1a3183846ca18bcb27d5cc21bcff979da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <stdio.h>
#include <string.h>
#include <openssl/md5.h>
//32 characters
int main (int arc, char * argv[]) {
MD5_CTX c;
char md5buffer[512];
int bytesread;
printf("Put something in the stdin of the program and it will generate a random block of text\n");
unsigned char md5result[16];
MD5_Init(&c);
do {
bytesread = fread(md5buffer, sizeof(char), 512, stdin);
if (bytesread < 0) {
printf("Error reading from STDIN\n");
return -1;
}
MD5_Update(&c, md5buffer, bytesread);
} while (bytesread != 0);
MD5_Final(md5result, &c);
printf("\n");
int i = 0;
while ( i < (16) ) {
printf("%.2x",md5result[i]);
i++;
}
printf("\n");
return 0;
}
|