LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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
  Search this Thread
Old 09-03-2008, 01:02 PM   #1
tnjones
LQ Newbie
 
Registered: Aug 2008
Posts: 27

Rep: Reputation: 15
How to use MD4, MD5, and SHA1 in Linux using C++


Hello,
I have this project where I have to give the user the option to apply MD4, MD5,or SHA1 in C++. Once the user selects one of the three specified hash functions, the program will apply the selected hash function to an arbitrary length local file named "input.txt". We were told that the functions are already implmented in Linux,at this time I would like to know how do you call such function in C++.Any help/advice would be greatly appreciated.

Thanks in Advance
 
Old 09-03-2008, 01:28 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170
Easily the best way to do such things is with the OpenSSL package and its associated libraries.

Each library that you use will provide a ".h" file which you #include to define the necessary routines. As with any library, there are several ways to cause the library to be linked-with and thus accessible-to your program, and you must employ one of them.

All of the "messy programming" then becomes just a black-box that your program can use. You can rely upon the implementation in that library to be well-tested and correct.
 
Old 09-03-2008, 06:13 PM   #3
tnjones
LQ Newbie
 
Registered: Aug 2008
Posts: 27

Original Poster
Rep: Reputation: 15
How to use MD4,MD5, SHA1 in Linux using C++

Thanks, that was helpful. However, I have another question. How would you apply the functon to a file. For example, say the user selects MD5, How would I apply MD5 to input.txt .
 
Old 09-04-2008, 12:14 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170Reputation: 3170
Well, you might be re-inventing existing commands like md5sum or the various command-line options of commands like openssl.

Before you spend too much time trying to figure out "how to write a program to do it," first see if such a program does not already exist. Almost certainly it does...
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with MD5 and SHA1 signatures DeepSeaNautilus Linux - Security 6 08-11-2008 10:51 PM
md5/sha1 Openssl libraries gives different output for binary files return.c Programming 1 03-24-2008 01:27 PM
password hash storage (md5, sha1...) aneroid Programming 6 12-30-2005 11:27 PM
Does my perrl have MD4 & MD5 clarkjwc Linux - Software 0 07-02-2004 05:50 PM
Getting SHA1... Red Guy Linux - Software 0 07-22-2003 11:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration