LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 12-07-2006, 10:00 PM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 244

Rep: Reputation: 30
c++ include md5


I would like write a program that will generate md5 sums based on files I will feed it. But I do not know how to include md5 capability into my program. What libraries should can I use and how do I implement them? Can anyone give me some recommendations? All it needs to do is take a file input, generate the sum, and return the string of the md5 sum. Simple huh?
 
Old 12-07-2006, 10:07 PM   #2
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian wheezy/sid, PC-BSD
Posts: 3,000
Blog Entries: 4

Rep: Reputation: 88
http://www.gnu.org/software/libc/man...ode/crypt.html

You should include crypt.h

Also for simple operations on md5sum, you can just call the md5sum executable using the system() command.

Last edited by vharishankar; 12-07-2006 at 10:10 PM.
 
Old 12-08-2006, 12:07 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu (x86), Debian (PPC)
Posts: 3,528

Rep: Reputation: 60
The GNU coreutils contain the source for the command line md5sum program.
 
Old 12-08-2006, 03:27 AM   #4
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 244

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by harishankar
http://www.gnu.org/software/libc/man...ode/crypt.html

You should include crypt.h

Also for simple operations on md5sum, you can just call the md5sum executable using the system() command.
Thanks. I tried that, but it seems I am missing something. I copied and pasted the example code from that website and my compiler gave me the error:

Code:
undefined reference to crypt
My program has #include<crypt.h> and that does not give an error....

About the system call, yeah. I know I could do that but I really would rather not, since it may be used on other systems eventually.
 
Old 12-08-2006, 06:37 AM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian wheezy/sid, PC-BSD
Posts: 3,000
Blog Entries: 4

Rep: Reputation: 88
Maybe you need to pass a linker flag like -lcrypt while compiling?

Just a thought.
 
Old 12-08-2006, 04:05 PM   #6
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 244

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by harishankar
Maybe you need to pass a linker flag like -lcrypt while compiling?

Just a thought.
That worked, thanks!
 
  


Reply

Tags
c++, crypt, include, md5


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
include/linux/types.h and include/linux/posix_types.h nocturna_gr Programming 2 11-26-2005 05:52 AM
md5 RDove Programming 3 03-07-2005 10:22 AM
using iso.md5 and iso.md5.asc Tyir Linux - Newbie 3 07-10-2004 11:45 PM
md5? juggernaught *BSD 1 03-28-2003 03:43 PM
Md5 Culbert Linux - General 2 03-13-2003 07:52 PM


All times are GMT -5. The time now is 01:15 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration