itszero (owner)

Revisions

gist: 99900 Download_button fork
public
Public Clone URL: git://gist.github.com/99900.git
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdio>
#include <cstdlib>
using namespace std;
 
char* md5(char* str)
{
char cmd[500];
sprintf(cmd, "echo -n \"%s\" | md5sum", str);
FILE *fd = popen(cmd, "r");
char *hash = (char*)malloc(sizeof(char) * 33);
hash[32] = NULL;
fread(hash, sizeof(char), 32, fd);
pclose(fd);
 
return hash;
}
 
int main()
{
printf("MD5 of HelloWorld: %s\n", md5("HelloWorld"));
}