473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to generate a md5 hash?

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

Nov 15 '05 #1
16 10699


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.

--
Er*********@sun .com

Nov 15 '05 #2
"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
Nov 15 '05 #3
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

Nov 15 '05 #4
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.

Nov 15 '05 #5
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
Nov 15 '05 #6
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.

Nov 15 '05 #7


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

Nov 15 '05 #8

"dutche" <du****@gmail.c om> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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
Nov 15 '05 #9
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:
Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
14431
by: pembed2003 | last post by:
Hi All, Does C++/STL have hashtable where I can do stuff like: Hashtable h<int>; h.store("one",1); h.store("two",2); and then later retrieve them like:
10
18563
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from tablename; Here this function generate unique id for each row of the table. Regards..
6
4457
by: Chang | last post by:
How to get SHA1 or MD5 of a big file (+5MB - 20GB) as I can't read 20GB into memory. -- Chang.
8
13371
by: mortb | last post by:
Hi, How do I write a GenerateHashcode function that will generate guaranteed unique hashcodes for my classes? cheers, mortb
3
2375
by: RossettoeCioccolato | last post by:
Is there a brief tutorial somewhere on how to use the VC8 linker to generate a manifest for an isolated application with a dependency section for an arbitrary dll? There are some implementation details that I don't understand. Supposing I want to bind my application to a specific version of kernel32.dll using a hash, for example? What hash...
21
3176
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been...
139
14073
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
4
2520
by: jimhce | last post by:
Hi, I want to generate a hash key from a string, and I want to the hash key is the same value for the same string. But it turns out all the hash functions I have tried, generate different keys from the same string. For example, if I run an excusable hash function several times in following example, it gave me all different values even the...
4
2447
by: ChipAuger | last post by:
Hello Group, Thank you in advance to the group for all responses and help. I'm looking for a 1-way hash for storing passwords on an older embedded system that would be computationally stressed using SHA1. Does anyone have any suggestions? Thanks again, Chip Auger
15
37569
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same string always, and generate different-2 Hash Code Different-2 string.
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.