Creating an MD5 hash with crypt.h

C

Carsten Maul

Hi,


I want to generate an MD5 checksum with crypt.h, installed OS Debian Woody.
Unfortunately I only get DES hashes with

strncpy(salt, row[0], 12);
salt[12] = '\0';
encryptedPass = crypt(passwd, salt);
free(salt);

Later I compare the two:

if (!strcmp(row[0], encryptedPass))

row[0] looks like that: $1$mYV0L3j8$nUUWy09JYrzdXurr92ywv1

salt starts with $1$ to indicate that I want an MD5 hash.

Unfortunately the encryptedPass looks like that:
1ba49f4d1ff0f49c

What am I doing wrong ? Did I forget anything ?

Thanks
 
M

Martin Ambuhl

Carsten said:
Hi,


I want to generate an MD5 checksum with crypt.h, installed OS Debian Woody.
Unfortunately I only get DES hashes with

strncpy(salt, row[0], 12);
salt[12] = '\0';
encryptedPass = crypt(passwd, salt);
free(salt);

Later I compare the two:

if (!strcmp(row[0], encryptedPass))

row[0] looks like that: $1$mYV0L3j8$nUUWy09JYrzdXurr92ywv1

salt starts with $1$ to indicate that I want an MD5 hash.

Unfortunately the encryptedPass looks like that:
1ba49f4d1ff0f49c

What am I doing wrong ? Did I forget anything ?

What you forgot was a question to do with C. There are newsgroups for
encryption and there are newsgroups for Linux. Try one of those.

Since there is no standard C function named 'crypt', there is nothing to
be said about that function without its being posted, together with a C
question rather than an algorithm question.
 
K

Kieran Simkin

Carsten Maul said:
Hi,


I want to generate an MD5 checksum with crypt.h, installed OS Debian
Woody.
Unfortunately I only get DES hashes with
[snip]

Try the crypt_set_format() section 3 manpage. I'm not sure if this is part
of any of the standard POSIX or UNIX specifications, as the history section
of my manpage doesn't say. If you ask this question in a newsgroup where it
is on-topic (comp.unix.programmer is probably a good place to ask), you will
get a better answer.


~Kieran Simkin
Digital Crocus
http://digital-crocus.com/
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top