MD5 function

This is a discussion on MD5 function within the C++ Programming forums, part of the General Programming Boards category; I have a php script that uses the php md5 function to hash a password and put it into a ...

  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,662

  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,211
    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
    21,647
    You could try the Crypto++ library.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

  10. #10
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    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, 06:18 AM
  5. Replies: 28
    Last Post: 07-16-2006, 11:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21