Thread: C++ md5()

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    219

    C++ md5()

    anybody knows a GOOD Platform Independent EASY TO USE C++ md5 librery

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    Nope Thats a C lib not C++ and That one I've got for C++ is not good at all.
    It was messing the header files names and lots of C code in C++ which refuses to compile due bad structure.
    as I am not getting any C++ lib I am trying to understand this C one which atleast compiles.
    However I dont want to use any lib that user need to install to get a DLL or so which will will be dynamically linked.
    I want a C++ Code that I can statically Compile with my programm.
    Thats why I cant simply use mhash cause its hard to extract the md5() code from it.
    Last edited by noobcpp; 07-22-2008 at 11:53 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Perhaps wrap the C code in a C++ class of your own.
    Sooner or later, you'll want to do this yourself, so consider this an opportunity to learn.

    It's not like MD5 has a complicated interface or anything.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    219
    anyway but I've made that semi broken C++ implementation working by borrowing some codes from the C version.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    hashlib++ seems to work OK, too.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Could someone please show some sample code that I could run using hashlib++(or a similar hashing function that uses MD5)?


    I am very new to programming!

    Thanks

  8. #8
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Download the hashlib++ library; there are examples contained in the package.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Thank you for your help, but when I run md5example.cpp I get many errors such as:

    md5example.cpp:1:23: hashlibpp.h: No such file or directory
    md5example.cpp:8: error: expected constructor, destructor, or type conversion before '*' token
    md5example.cpp:8: error: expected `,' or `;' before '*' token
    md5example.cpp:10: error: expected unqualified-id before "try"
    md5example.cpp:10: error: expected `,' or `;' before "try"
    md5example.cpp:22: error: expected unqualified-id before "catch"
    md5example.cpp:22: error: expected `,' or `;' before "catch"
    md5example.cpp:32: error: expected unqualified-id before "delete"
    md5example.cpp:32: error: expected `,' or `;' before "delete"


    Any ideas??

    Thanks!

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Don't delete hashlibpp.h before you start? (Or, alternatively, put in the directory along with everything else, or make sure you download it in the first place.)

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    I did think it was very odd for me to get an error saying "md5example.cpp:1:23: hashlibpp.h: No such file or directory"

    I changed the top of the code to

    Code:
    #include <string.h>
    #include <iostream.h>  //for "cerr"
    include "hashlibpp.h"
    That problem is gone, however I now get:

    In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,
    from md5example.cpp:2:
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    md5example.cpp:8: error: expected constructor, destructor, or type conversion before string constant
    md5example.cpp:8: error: expected `,' or `;' before string constant
    md5example.cpp:10: error: expected unqualified-id before "try"
    md5example.cpp:10: error: expected `,' or `;' before "try"
    md5example.cpp:22: error: expected unqualified-id before "catch"
    md5example.cpp:22: error: expected `,' or `;' before "catch"
    md5example.cpp:32: error: expected unqualified-id before "delete"
    md5example.cpp:32: error: expected `,' or `;' before "delete"

    I don't understand!!

  12. #12
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #13
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by zodiacWarrior View Post
    I did think it was very odd for me to get an error saying "md5example.cpp:1:23: hashlibpp.h: No such file or directory"

    I changed the top of the code to

    Code:
    #include <string.h>
    #include <iostream.h>  //for "cerr"
    include "hashlibpp.h"
    That problem is gone, however I now get:

    In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,
    from md5example.cpp:2:
    /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    md5example.cpp:8: error: expected constructor, destructor, or type conversion before string constant
    md5example.cpp:8: error: expected `,' or `;' before string constant
    md5example.cpp:10: error: expected unqualified-id before "try"
    md5example.cpp:10: error: expected `,' or `;' before "try"
    md5example.cpp:22: error: expected unqualified-id before "catch"
    md5example.cpp:22: error: expected `,' or `;' before "catch"
    md5example.cpp:32: error: expected unqualified-id before "delete"
    md5example.cpp:32: error: expected `,' or `;' before "delete"

    I don't understand!!
    Using iostream.h is evil and a sin. The header is called <iostream>, no .h at the end.

    ETA: Also, I don't believe the rest of the error messages, because although you added two lines to the source code (as noted from the error message on line 2), the other errors did not move down two lines. And you did do #include, not just include, right?
    Last edited by tabstop; 07-29-2008 at 06:17 PM.

  14. #14
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Thanks for the tips. The following code:

    Code:
    #include <string.h>
    #include <iostream>  //for "cerr"
    #include "hashlibpp.h"

    generates the following error messages:

    In file included from md5example.cpp:3:
    hashlibpp.h:43:28: hl_hashwrapper.h: No such file or directory
    hashlibpp.h:44:27: hl_md5wrapper.h: No such file or directory
    hashlibpp.h:45:28: hl_sha1wrapper.h: No such file or directory
    hashlibpp.h:46:30: hl_sha256wrapper.h: No such file or directory
    hashlibpp.h:47:30: hl_sha384wrapper.h: No such file or directory
    hashlibpp.h:48:30: hl_sha512wrapper.h: No such file or directory
    md5example.cpp:8: error: expected constructor, destructor, or type conversion before '*' token
    md5example.cpp:8: error: expected `,' or `;' before '*' token
    md5example.cpp:10: error: expected unqualified-id before "try"
    md5example.cpp:10: error: expected `,' or `;' before "try"
    md5example.cpp:22: error: expected unqualified-id before "catch"
    md5example.cpp:22: error: expected `,' or `;' before "catch"
    md5example.cpp:32: error: expected unqualified-id before "delete"
    md5example.cpp:32: error: expected `,' or `;' before "delete"

  15. #15
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Quote Originally Posted by Mario F. 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



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