| Path: | news.grnet.gr!not-for-mail | 
| From: | Diomidis Spinellis <dds@aueb.gr> | 
| Newsgroups: | comp.lang.c | 
| Subject: | Re: How to encrypt a password | 
| Date: | Tue, 11 Apr 2006 17:35:53 +0300 | 
| Organization: | Athens University of Economics and Business | 
| Lines: | 59 | 
| Message-ID: | <e1gesa$b79$1@volcano1.grnet.gr> | 
| References: | <1144764600.822078.24580@i40g2000cwc.googlegroups.com> | 
| NNTP-Posting-Host: | dhcp7.dmst.aueb.gr | 
| Mime-Version: | 1.0 | 
| Content-Type: | text/plain; charset=ISO-8859-1; format=flowed | 
| Content-Transfer-Encoding: | 7bit | 
| NNTP-Posting-Date: | Tue, 11 Apr 2006 14:35:54 +0000 (UTC) | 
| User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 | 
| In-Reply-To: | <1144764600.822078.24580@i40g2000cwc.googlegroups.com> | 
Dan_track wrote:
> 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
Newsgroup comp.lang.c contents 
Newsgroup list 
Diomidis Spinellis home page
 
 Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.