473,699 Members | 2,417 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
16 10715

"Mark" <so***@localbar .com> wrote in message
news:Vh******** ***********@new shog.newsread.c om...

"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


Worth mentioning: You'll also need to compile md5.c
$ gcc md5.c mddriver.c -o [whatever]

Mark
Nov 15 '05 #11
"dutche" <du****@gmail.c om> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
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' gcc md5.c mddriver.c -o mddriver

And the errors I got was...

caused by an bug in the code.
line 20 mddriver.c
#define MD MD5
should be
#define MD 5
Nov 15 '05 #12
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)


There are some errors in that source code at
http://www.faqs.org/rfcs/rfc1321.html :

md5c.c line 82 (the blank line) should be deleted
mddriver.c line 21 should read:
#define MD 5
instead of
#define MD MD5

Note that md5c.c contains the functions for performing an MD5
operation (suitable for embedding in another project), and
mddriver.c is a commandline program that you can use to
call these functions.
If all you want to do is add these functions to another project
of yours, then you only need md5c.c .

Note that you have to tell GCC about all the source files you
want to compile:

gcc -o mddriver mddriver.c md5c.c

It's also a good idea to enable warnings:

gcc -o mddriver mddriver.c md5c.c -Wextra -Wall -ansi -pedantic

mddriver.c has a couple of warnings when compiled with these
switches, but they are ones you can safely ignore.

Finally, the source code in that RFC is a little archaic,
if you do a 'locate md5.c' on your system you will probably turn
up a lot of other implementations of it. For example, the PHP
source code contains it.

Nov 15 '05 #13
Is that point that I need to reach, I found that md5.c is the functions
to generate a hash right?
But (as I said I'm new in 'C') I cant realize which function is the
"hash maker".

Sorry, I'm still reading the K&R book but not too familiarized yet.

Nov 15 '05 #14
Red
In article <11************ *********@g47g2 000cwa.googlegr oups.com>,
ja**********@gm ail.com says...

Please, learn how to ask an intelligent, useful question.


Please, learn how NOT to be a rude asswipe.
Nov 15 '05 #15
Red wrote:
In article <11************ *********@g47g2 000cwa.googlegr oups.com>,
ja**********@gm ail.com says...
Please, learn how to ask an intelligent, useful question.

Please, learn how NOT to be a rude asswipe.


While it is occasionally enjoyable to see a self-referential post, yours
is not at all amusing.
Nov 15 '05 #16
Martin Ambuhl wrote:
Red wrote:
ja**********@gm ail.com says...
Please, learn how to ask an intelligent, useful question.


Please, learn how NOT to be a rude asswipe.


While it is occasionally enjoyable to see a self-referential post,
yours is not at all amusing.


No, but it does an admirable job of inciting PLONKs up and down the
seacoast.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 15 '05 #17

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

Similar topics

34
14468
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
18599
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
4465
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
13380
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
2383
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 is used? Is it the hash generated by the CryptCATAdmin* functions or just a simple hash of the...
21
3213
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 thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
139
14171
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
2526
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 string does not change: $ BobJenkinHash "hello" 0x183B3443 $ BobJenkinHash "hello" 0x24082445
4
2453
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
37591
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
8613
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.