Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How to generate a md5 hash?

Reply
Thread Tools

How to generate a md5 hash?

 
 
dutche
Guest
Posts: n/a
 
      07-20-2005
Hi, this is my first post here and I'm very very new in 'C'
programming.
And I began to 'translate' my PHP program, that beyond a lot of things
generates a md5 hash, and I must generate a md5 hash in 'C' , but I
cant found it anywhere.
I've readed the crypt.h man page, I read twice the post in
http://groups.google.com.br/group/co...4b37481e4d0b48

But I still dont know how to generate a md5 hash from my string
'testing' for example.

Plz, if anyone can help me I'd be glad

Thanks

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      07-20-2005


dutche wrote:
> Hi, this is my first post here and I'm very very new in 'C'
> programming.
> And I began to 'translate' my PHP program, that beyond a lot of things
> generates a md5 hash, and I must generate a md5 hash in 'C' , but I
> cant found it anywhere.
> I've readed the crypt.h man page, I read twice the post in
> http://groups.google.com.br/group/co...4b37481e4d0b48
>
> But I still dont know how to generate a md5 hash from my string
> 'testing' for example.


The RFC that defines MD5 contains a sample C
implementation.

--
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      07-20-2005
"dutche" writes:

> Hi, this is my first post here and I'm very very new in 'C'
> programming.
> And I began to 'translate' my PHP program, that beyond a lot of things
> generates a md5 hash, and I must generate a md5 hash in 'C' , but I
> cant found it anywhere.
> I've readed the crypt.h man page, I read twice the post in
> http://groups.google.com.br/group/co...4b37481e4d0b48
>
> But I still dont know how to generate a md5 hash from my string
> 'testing' for example.
>
> Plz, if anyone can help me I'd be glad


Did you look at this?

http://www.faqs.org/rfcs/rfc1321.html


 
Reply With Quote
 
dutche
Guest
Posts: n/a
 
      07-20-2005
Yes, I've readed the entire RFC, but as I said...I'm very new in 'C'
and I copied the files that is in Appendix.

At this point, everything's fine...but when I try to compile
it...like...I donno how to compile those files togheter.

I tried 'gcc mddriver.c -o mddriver' , and a lot of errors appears to
me :/

I'm posting here cause I tried everything that I can with no results.

Thanks

 
Reply With Quote
 
james.jdunne@gmail.com
Guest
Posts: n/a
 
      07-20-2005
dutche wrote:
> Yes, I've readed the entire RFC, but as I said...I'm very new in 'C'
> and I copied the files that is in Appendix.
>
> At this point, everything's fine...but when I try to compile
> it...like...I donno how to compile those files togheter.
>
> I tried 'gcc mddriver.c -o mddriver' , and a lot of errors appears to
> me :/
>
> I'm posting here cause I tried everything that I can with no results.
>
> Thanks


Please, learn how to ask an intelligent, useful question. Then someone
may help you without wasting posts asking for this and that.

With that said, here is the minimal amount of information needed to
help you:

1) Are you using separate source files? Do you have the MD5
implementation in a separate file or did you copy/paste it into
mddriver.c?
2) What are the errors you get from gcc (please copy/paste, don't
summarize)?
3) What are the relevant source files involved in your project?

At this point, I'd suggest, for simplicity's sake, to simply copy/paste
the MD5 code to the TOP of your mddriver.c source file and place your
int main() function at the bottom of the source file.

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      07-20-2005
dutche wrote:

> Yes, I've readed the entire RFC, but as I said...I'm very new in 'C'
> and I copied the files that is in Appendix.



Please quote a relevant portion of the previous message for context.
Check CB Falconer messages for instructions.

> At this point, everything's fine...but when I try to compile
> it...like...I donno how to compile those files togheter.
>
> I tried 'gcc mddriver.c -o mddriver' , and a lot of errors appears to
> me :/
>
> I'm posting here cause I tried everything that I can with no results.



And what are we supposed to do, psychically divine what code you are
trying?




Brian
 
Reply With Quote
 
dutche
Guest
Posts: n/a
 
      07-20-2005
First, I created these files:

global.h
md5.h
md5c.c
mddriver.c

Ok, I made it exactly as described but when I try to compile I dont got
any results, I think that I'm doing something wrong when compiling.

I've copied the source of the programs directly from the RFC site, and
the command that I used is: 'gcc mddriver.c -o mddriver'

And the errors I got was...

mddriver.c: In function `MDString':
mddriver.c:106: error: `MD_CTX' undeclared (first use in this function)
mddriver.c:106: error: (Each undeclared identifier is reported only
once
mddriver.c:106: error: for each function it appears in.)
mddriver.c:106: error: parse error before "context"
mddriver.c:110: error: `context' undeclared (first use in this
function)
mddriver.c:114: error: `MD5' undeclared (first use in this function)
mddriver.c: In function `MDTimeTrial':
mddriver.c:124: error: `MD_CTX' undeclared (first use in this function)
mddriver.c:124: error: parse error before "context"
mddriver.c:130: error: `MD5' undeclared (first use in this function)
mddriver.c:141: error: `context' undeclared (first use in this
function)
mddriver.c: In function `MDTestSuite':
mddriver.c:162: error: `MD5' undeclared (first use in this function)
mddriver.c: In function `MDFile':
mddriver.c:183: error: `MD_CTX' undeclared (first use in this function)
mddriver.c:183: error: parse error before "context"
mddriver.c:191: error: `context' undeclared (first use in this
function)
mddriver.c:198: error: `MD5' undeclared (first use in this function)
mddriver.c: In function `MDFilter':
mddriver.c:208: error: `MD_CTX' undeclared (first use in this function)
mddriver.c:208: error: parse error before "context"
mddriver.c:212: error: `context' undeclared (first use in this
function)



I'm using a Slackware Linux 10.1 with gcc-3.3.4-i486-1.

Sorry for the few arguments in the last post.

 
Reply With Quote
 
Chris Hulbert
Guest
Posts: n/a
 
      07-20-2005


dutche wrote:
> First, I created these files:
>
> global.h
> md5.h
> md5c.c
> mddriver.c
>
> Ok, I made it exactly as described but when I try to compile I dont got
> any results, I think that I'm doing something wrong when compiling.
>
> I've copied the source of the programs directly from the RFC site, and
> the command that I used is: 'gcc mddriver.c -o mddriver'
>
> And the errors I got was...
>
> mddriver.c: In function `MDString':
> mddriver.c:106: error: `MD_CTX' undeclared (first use in this function)
> mddriver.c:106: error: (Each undeclared identifier is reported only
> once
> mddriver.c:106: error: for each function it appears in.)
> mddriver.c:106: error: parse error before "context"
> mddriver.c:110: error: `context' undeclared (first use in this
> function)
> mddriver.c:114: error: `MD5' undeclared (first use in this function)
> mddriver.c: In function `MDTimeTrial':
> mddriver.c:124: error: `MD_CTX' undeclared (first use in this function)
> mddriver.c:124: error: parse error before "context"
> mddriver.c:130: error: `MD5' undeclared (first use in this function)
> mddriver.c:141: error: `context' undeclared (first use in this
> function)
> mddriver.c: In function `MDTestSuite':
> mddriver.c:162: error: `MD5' undeclared (first use in this function)
> mddriver.c: In function `MDFile':
> mddriver.c:183: error: `MD_CTX' undeclared (first use in this function)
> mddriver.c:183: error: parse error before "context"
> mddriver.c:191: error: `context' undeclared (first use in this
> function)
> mddriver.c:198: error: `MD5' undeclared (first use in this function)
> mddriver.c: In function `MDFilter':
> mddriver.c:208: error: `MD_CTX' undeclared (first use in this function)
> mddriver.c:208: error: parse error before "context"
> mddriver.c:212: error: `context' undeclared (first use in this
> function)
>
>
>
> I'm using a Slackware Linux 10.1 with gcc-3.3.4-i486-1.
>
> Sorry for the few arguments in the last post.


This newsgroup isn't really for helping you learn to compile C code.
Nonetheless, notice you have multiple source files, but only used one
of them in your compile statement. Try something more like:

gcc -c -v -Wall -I. -omd5.o md5.c
gcc -c -v -Wall -I. -omddriver.o mddriver.c
gcc -omddriver mddriver.o md5.o

 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      07-20-2005

"dutche" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Yes, I've readed the entire RFC, but as I said...I'm very new in 'C'
> and I copied the files that is in Appendix.
>
> At this point, everything's fine...but when I try to compile
> it...like...I donno how to compile those files togheter.
>
> I tried 'gcc mddriver.c -o mddriver' , and a lot of errors appears to
> me :/
>
> I'm posting here cause I tried everything that I can with no results.


That's because the code provided with the RFC has a bug
At approximately line 20 or mddriver.c replace the following line:

#define MD MD5
with
#define MD 5

That's should do the trick.

Regards,
Mark


 
Reply With Quote
 
dutche
Guest
Posts: n/a
 
      07-20-2005
In the first compile I got errors:
The command:
gcc -c -v -Wall -I. -omd5.o md5c.c

The errors:

GGC heuristics: --param ggc-min-expand=46 --param
ggc-min-heapsize=31005
ignoring nonexistent directory "/usr/i486-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
.
/usr/local/include
/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/include
/usr/include
End of search list.
md5c.c:81: error: parse error before '+=' token
md5c.c:81:13: warning: backslash and newline separated by space
md5c.c: In function `MD5Transform':
md5c.c:340: error: parse error at end of input
md5c.c:50: warning: `Encode' declared `static' but never defined
md5c.c:52: warning: `Decode' declared `static' but never defined
md5c.c:54: warning: `MD5_memcpy' declared `static' but never defined
md5c.c:55: warning: `MD5_memset' declared `static' but never defined


Thanks for help

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
create a md5 / md5 passwd with a salt Peter Woodsky Ruby 6 11-21-2008 09:08 AM
md5 from python different then md5 from command line ursache.marius@gmail.com Python 9 05-07-2006 11:49 PM
How to generate an MD5 data from the string Peter Afonin ASP .Net 3 08-24-2004 09:09 AM
I remember someone asking about an MD5 javascript: http://pajhome.org.uk/crypt/md5/ Mozzie \( v \) Javascript 0 07-12-2004 01:06 PM



Advertisments