Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. md5

md5

Scheduled Pinned Locked Moved C / C++ / MFC
c++cryptographyquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam 2006
    wrote on last edited by
    #1

    how can i get the md5 hash of something in mfc

    C J J L 4 Replies Last reply
    0
    • S Sam 2006

      how can i get the md5 hash of something in mfc

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      google - there are plenty of MD5 examples available online. Christian Graus - Microsoft MVP - C++

      S 1 Reply Last reply
      0
      • C Christian Graus

        google - there are plenty of MD5 examples available online. Christian Graus - Microsoft MVP - C++

        S Offline
        S Offline
        Sam 2006
        wrote on last edited by
        #3

        thats what i am doing write now... but all i am finding is forums about ppl asking what php's md5() function is for...

        C 1 Reply Last reply
        0
        • S Sam 2006

          thats what i am doing write now... but all i am finding is forums about ppl asking what php's md5() function is for...

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          First hit[^] You need to think about what you type into google. I typed md5 C++ source code. md5 by itself would obviously get a lot of other hits. Christian Graus - Microsoft MVP - C++

          1 Reply Last reply
          0
          • S Sam 2006

            how can i get the md5 hash of something in mfc

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #5

            Any set of C functions would integrate nicely with MFC. Here's[^] one C-implementation. All you have to do is to copy'n'paste, and you're set.

            char text[] = "your text here";
            md5_context ctx;
            md5_starts(&ctx);
            md5_update(&ctx, (unsigned char*)text, sizeof(text));
            unsigned char md5hash[16];
            md5_finish(&ctx, md5hash);

            There you go! Please note that the contents of md5hash will be in binary format. It's not a string, it's an array of exactly 16 bytes. If you need to convert it into a string, then you'll have to do something like this:

            char hashtext[33];
            for(int i = 0; i < 16; ++i) {
            unsigned char hinibble = ((md5hash[i] & 0xF0) >> 4);
            unsigned char lonibble = md5hash[i] & 0xF;
            hashtext[i * 2] = hinibble >= ? (hinibble - 10) + 'A' : hinibble + '0';
            hashtext[i * 2 + 1] = lonibble >= ? (lonibble - 10) + 'A' : lonibble + '0';
            }
            hashtext[32] = 0; // terminate string

            hashtext will now contain the hash on a hexadecimal form. Also note that the input can be any kind of data, it doesn't have to be text! Any byte chunk would do. Good music: In my rosary[^]

            1 Reply Last reply
            0
            • S Sam 2006

              how can i get the md5 hash of something in mfc

              J Offline
              J Offline
              Jim Howard
              wrote on last edited by
              #6

              I've had an md5 implementation here on Codeproject for years and years. It works fine, although its pretty old fashioned code. There are several other MD5 examples here. You can also use the MS Crypto API, look up the documentation for CryptCreateHash in Platform SDK.

              1 Reply Last reply
              0
              • S Sam 2006

                how can i get the md5 hash of something in mfc

                L Offline
                L Offline
                logicaldna
                wrote on last edited by
                #7

                you have some help on codeproject befor doing google always check codeproject http://www.codeproject.com/cpp/cryptest.asp Love is photogenic,It requires a dark to develope.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups