How to encrypt a password

D

Dan_track

Hi

I'm new to c. What I'd like to do is md5 hash a password, but I'm
having problems with the basics. My main problem is I'm wobbly on
knowing where to start from. I assumed I'd use md5.h in my program, but
how do I know what functons to use or exist to be used?

Could somone help me with this?

Thanks in advance
Dan
 
D

Diomidis Spinellis

Dan_track said:
I'm new to c. What I'd like to do is md5 hash a password, but I'm
having problems with the basics. My main problem is I'm wobbly on
knowing where to start from. I assumed I'd use md5.h in my program, but
how do I know what functons to use or exist to be used?

Could somone help me with this?

The md5 libraries are not part of the standard C, so your question
depends on what support is available on the system you are using. If
you're on a Unix system the manual pages are your friend. For example
on my FreeBSD system the command:

$ man 3 md5

gives me the following:

MD5(3) FreeBSD Library Functions Manual

NAME
MD5Init, MD5Update, MD5Pad, MD5Final, MD5End, MD5File, MD5Data --
calculate the RSA Data Security, Inc., ``MD5'' message digest

LIBRARY
Message Digest (MD4, MD5, etc.) Support Library (libmd, -lmd)

SYNOPSIS
#include <sys/types.h>
#include <md5.h>

void
MD5Init(MD5_CTX *context);

void
MD5Update(MD5_CTX *context, const unsigned char *data, unsigned
int len);

void
MD5Pad(MD5_CTX *context);

void
MD5Final(unsigned char digest[16], MD5_CTX *context);

char *
MD5End(MD5_CTX *context, char *buf);

char *
MD5File(const char *filename, char *buf);

char *
MD5Data(const unsigned char *data, unsigned int len, char *buf);

[...]

The MD5Init(), MD5Update(), and MD5Final() functions are the core
functions. Allocate an MD5_CTX, initialize it with MD5Init(), run over
thedata with MD5Update(), and finally extract the result using MD5Final().

Diomidis - http://www.spinellis.gr
 
D

Dan_track

Hi

Thanks for the reply.

I'm using fedora core 3 linux.

If md5 is not the right the right library can you direct me to the
right one.

Thanks
Dan
 
K

Keith Thompson

Dan_track said:
Thanks for the reply.

What reply? To what?

Read said:
I'm using fedora core 3 linux.

If md5 is not the right the right library can you direct me to the
right one.

No, at least not in this newsgroup. There is no md5 support in
standard C, which is what we discuss here (though of course md5
algorithms can be implemented in standard C). If your operating
system provides md5 support, you can find out about it by reading your
system's documentation. If that fails, try Google. If *that* fails,
try a more appropriate newsgroup, either comp.unix.programmer or one
of the Linux groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top