hathor-cpp-scanner/md5.cc

44 lines
854 B
C++

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <openssl/md5.h>
using namespace std;
char *hathor_md5( const char * str ) {
static char result[32]; // MD5 Result
unsigned char buffer_md5[16]; // Buffer to hold MD5
char buf[2]; // Temporary sprintf buffer
MD5_CTX md5;
MD5_Init (&md5);
MD5_Update (&md5, (const unsigned char *) str, strlen(str) );
MD5_Final ( buffer_md5, &md5);
for ( unsigned int i = 0; i < 16; i++ ) {
sprintf(buf, "%02x", buffer_md5[i]);
strcat(result,buf);
}
return result;
}
/*
int main( int argc, char ** argv ) {
if( argc > 1 ) {
cout << md5( argv[1] ) << endl;
}
else {
char in[100];
printf("Enter password : ");
scanf("%s", in);
//char* hash = md5(in);
cout << md5(in) << endl;
}
return 0;
}
*/