Hash/encrypt a password

hi there,
is there any easier way to hash a password using MD5?
coz i search most of the website is just the coding to do it,
but is there any way to do it easily?
like using a MD5 software to do it or using the unix command
-openssl md5 password
can this be done?
What? You want to write an implementation of the MD5 algorithm, or you want to find some software that can make hashes?

If it's the former, http://en.wikipedia.org/wiki/MD5
If it's the latter, use the md5sum command/
sorry, maybe i didt say about my situation.
currently i want to create a login system.
i have done those login parts and save my username and password into a text file.
now i want to encrypt my password using MD5 before save into a text file.
so :
1
2
3
4
5
6
is there any easier way to hash a password using MD5?
coz i search most of the website is just the coding to do it,
but is there any way to do it easily?
like using a MD5 software to do it or using the unix command
-openssl md5 password
can this be done?
Well, Python has a library function to hash things, you could look into that?

If you want the MD5 hash of the password, you can use the UNIX command md5sum.
err i found a command in unix:
echo -n “hello” | md5sum

this is use to hash the value hello in to hashes value rite?
so in C++ i use the code:
system("echo -n “password” | md5sum") to hash my password.

how can i make x = hashes value?
x = system("echo -n “password” | md5sum")

besides, if using the command system("echo -n “password” | md5sum") the result will show out in prompt. how i disable it?
closed account (z05DSL3A)
Take a look at Crypto++® Library
http://www.cryptopp.com/

or if you have the time and inclination; get a copy of RFC 1321 - The MD5 Message-Digest Algorithm and write your own function.

http://www.faqs.org/rfcs/rfc1321.html
Last edited on
It is better to use the crypto++ library as suggested by Grey Wolf. If you still want to use a system kind of function, take a look at popen function:
Example would be:

#include <stdio.h>
#define MAX 1024
int main()
{
FILE *fp;
int status;
char path[MAX];
fp = popen("echo -n \"password\" | md5sum" , "r");
if (fp == NULL)
{
perror("popen failed");
}
while (fgets(path, MAX, fp) != NULL)
{
printf("%s", path);
}
status = pclose(fp);
return(0);
}
OpenSSL has MD5 hash functions. That's got to be a hell of a lot easier than using popen.
sorry being late reply, anyway thx for the solution.
Topic archived. No new replies allowed.