Thread: MD5 function

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    54

    MD5 function

    I have a php script that uses the php md5 function to hash a password and put it into a database.

    I then read the password to a std string, it's a hexdecimal value..

    Now I want a c++ function to hash the password and then compare the two..

    Is there a standard MD5 library or can anyone recommend one for me to use, thanks..

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    man, that was really helpful >_>

    but not..

    can anyone recommend a library that could easily solve my problem..

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, you don't want to FIND A LIBRARY, but rather you want someone here tell you WHICH LIBRARY to use?

    There isn't a standard one, but there are plenty of different ones available if you add "library" to your google-string. I have no idea which one(s) are most suitable for what you want to do [you'd have to tell us if you want one for Linux, Windows, both or something else, for one thing - does it have to be portable between multiple compilers, or just one].

    By the way, what are you actually trying to solve? If you are trying to "improve the performance" of the PHP script, I think you'll struggle, as the MD5 implementation in PHP is 99% certainly written in efficient C/C++ anyways.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    I was hoping someone could recommend a good one..

    I am making a game. User's create accounts on a website. Their passwords get hashed for storage in the database by php.

    Then when they come to play the game, which is written in c++ they will need to login.

    To verify the password I need to compute the hash in C++ and compare it with the one in the database..

    I was just hoping that someone had done something like this before and knew of a good library or header file that would give me simple MD5 functionality..

    Thanks


  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Yeah I found an MD5 implementation written in C when I needed one, but I can't remember where exactly it was from. I googled for it, and checked wikipedia for a library in their external links on the MD5 page.

    Just fyi, I don't plan on googling for you. JGI.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You could try the Crypto++ library.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    I have to say I am struggling to find anything I can get to work. I spent 30 mins trying to make sense of crypto++, but have no idea what i'm meant to do to get it to work.

    I want something easy where I can just use a dll or statically linked library, include a header in my project then call a simple md5 function

    i can't find anything this simple so far can anyone help?

  9. #9

  10. #10
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Google for "md5.c". Look for the implementation by L. Peter Deutsch. It's about as simple an interface as it gets.

  11. #11
    Registered User
    Join Date
    Jan 2007
    Posts
    54
    it took ages but i finally found this site:

    http://md5hashing.com/c++/

    it's got md5 implementations for loads of languages..

    before i found this i had spent some time trying to get XySSL to work, and when i finally did it generated a different hash to the one generated by PHP >_<

    anyhow http://md5hashing.com/c++/ is really simple and works with PHP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  5. Replies: 28
    Last Post: 07-16-2006, 11:35 PM