Thread: C++ md5()

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by zodiacWarrior View Post
    When I try to run their suggested quote, I get:

    /cygdrive/c/DOCUME~1/mehrdad/LOCALS~1/Temp/ccpcV0op.o:myMD5.cpp.text+0x79): undefined reference to `md5wrapper::md5wrapper()'
    /cygdrive/c/DOCUME~1/mehrdad/LOCALS~1/Temp/ccpcV0op.o:myMD5.cpp.text+0xd7): undefined reference to `md5wrapper::getHashFromString(std::basic_string<c har, std::char_traits<char>, std::allocator<char> >)'
    /cygdrive/c/DOCUME~1/mehrdad/LOCALS~1/Temp/ccpcV0op.o:myMD5.cpp.text+0x1b3): undefined reference to `md5wrapper::getHashFromFile(std::basic_string<cha r, std::char_traits<char>, std::allocator<char> >)'
    /cygdrive/c/DOCUME~1/mehrdad/LOCALS~1/Temp/ccpcV0op.o:myMD5.cpp.text+0x2c8): undefined reference to `md5wrapper::~md5wrapper()'
    /cygdrive/c/DOCUME~1/mehrdad/LOCALS~1/Temp/ccpcV0op.o:myMD5.cpp.text+0x322): undefined reference to `md5wrapper::~md5wrapper()'
    collect2: ld returned 1 exit status


    Did you type "g++ md5wrapper.cpp md5.cpp" on the command line, or just md5.cpp?

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You need all those .h files too.

  3. #18
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Quote Originally Posted by tabstop View Post
    Did you type "g++ md5wrapper.cpp md5.cpp" on the command line, or just md5.cpp?
    Thank you so much. This seems to have done the trick and I no longer get error messages. However, when I run the program, I get nothing from the output. How can I print out what the MD5 hash for "Hello World" is? Is the hash stored in the variable hash1?

    The reason I am confused is because the variable hash1 was not declared...unless it is declared elsewhere? The code that I am running is as follows:

    Code:
    #include "md5wrapper.h"
    
    int main( int argc, char** argv )
    {
    	// creating a wrapper object
    	md5wrapper md5;
    
    	// create a hash from a string
    	std::string hash1 = md5.getHashFromString("Hello World");
    
    	// create a hash from a file
    	std::string hash2 = md5.getHashFromFile("readme.txt");
    
    	return 0;
    }

  4. #19
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by zodiacWarrior View Post
    Code:
    #include "md5wrapper.h"
    
    int main( int argc, char** argv )
    {
    	// creating a wrapper object
    	md5wrapper md5;
    
    	// create a hash from a string
    	std::string hash1 = md5.getHashFromString("Hello World"); //hash1 conveniently stored right here
    
    	// create a hash from a file
    	std::string hash2 = md5.getHashFromFile("readme.txt");
    
    	return 0;
    }
    Yes, if you want to see it, you'll need to send that string to cout.

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by zodiacWarrior View Post
    Code:
    #include "md5wrapper.h"
    
    int main( int argc, char** argv )
    {
    	// creating a wrapper object
    	md5wrapper md5;
    
    	// create a hash from a string
    	std::string hash1 = md5.getHashFromString("Hello World"); //hash1 conveniently declared right here
    	// create a hash from a file
    	std::string hash2 = md5.getHashFromFile("readme.txt");
    
    	return 0;
    }
    Yes, if you want to see it, you'll need to send that string to cout.

  6. #21
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Thank you for your help, I think I have it now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compare running programs' MD5 and terminate
    By ferenczi in forum C Programming
    Replies: 3
    Last Post: 02-08-2008, 02:56 PM
  2. File send app - md5 checksum different when load is put on server.
    By (Slith++) in forum Networking/Device Communication
    Replies: 5
    Last Post: 12-31-2007, 01:23 PM
  3. Some questions concerning smp and md5
    By keira in forum C Programming
    Replies: 6
    Last Post: 08-31-2007, 03:03 PM
  4. MD5 Hash
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 06-12-2003, 06:26 AM
  5. Implementing the MD5 encryption library in C
    By Weed4Me in forum C Programming
    Replies: 12
    Last Post: 11-09-2001, 03:10 PM