Results 1 to 12 of 12

Thread: MD5 hash calculator

  1. #1
    ChemicalX
    Guest

    Post MD5 hash calculator

    Im just starting Crypto Keygenning in Visual C++ and am having a hard time trying to make a simple program to calculate a MD5 hash from a name.

    Ive seen many programs from Crypto Keygen websites that do this but they all dont include sources.

    If possible can anyone direct me to a sample application with source or show me how its done.



    Thanks
    Last edited by ChemicalX; September 12th, 2004 at 16:59.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  2. #2
    cr.ap
    Guest
    http://www.faqs.org/rfcs/rfc1321.html

    or use any of the crypto libraries which come with source Crypto++, libtomcrypt etc.
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  3. #3
    search button
    google too, read the fking faq

    http://www.google.com/search?q=md5.asm&sourceid=firefox&start=0&start=0&ie=utf-8&oe=utf-8

    how hard was that?

  4. #4
    son of Bungo & Belladonna bilbo's Avatar
    Join Date
    Mar 2004
    Location
    Rivendell
    Posts
    310
    Quote Originally Posted by evlncrn8
    md5.asm
    well, since he asked for MS C++ project, he could have googled for
    md5.cpp
    1320 results...

    If he doesn't like googling, he can try this
    ftp://ftp.zedz.net/pub/crypto/hashes/mds/md5/

    Regards, bilbo
    Non quia difficilia sunt, non audemus, sed quia non audemus, difficilia sunt.[Seneca, Epistulae Morales 104, 26]

  5. #5
    I did it in the following way:


    ;--------------------------------------------------
    ;MD5 hash stuff from advapi32
    ;--------------------------------------------------
    invoke CryptAcquireContext, ADDR phProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ;setup..
    test eax, eax
    jz _err

    invoke CryptCreateHash, phProv, CALG_MD5, 0, 0, ADDR phHash ;..to MD5
    test eax, eax
    jz _err

    invoke CryptHashData, phHash, ADDR buf1, buf1Len, 0 ;do MD5, it's possible to add more data..
    test eax, eax ;..with following CryptHashData APIs
    jz _err

    mov buf1Len, 10h
    invoke CryptGetHashParam, phHash, HP_HASHVAL, ADDR buf1, ADDR buf1Len, 0 ;get result
    test eax, eax
    jz _err

    invoke CryptDestroyHash, phHash ;destroy..
    test eax, eax
    jz _err

    invoke CryptReleaseContext, phProv, 0 ;..and release
    test eax, eax
    jz _err


    Not a c++ though.
    Neviens.

  6. #6
    ChemicalX
    Guest
    FYI ive searched google and found the md5.h/md5.cpp before. Its after that my problem comes.

    I do the following code:
    MD5_Init(&MD5);
    MD5_Update(&MD5, (unsigned char*)Name, strlen(Name));
    MD5_Final((unsigned char*)MD5_bytes, &MD5);

    That i presume leaves the MD5 hash at MD5_Bytes.
    The problem comes when i try to print that.

    I found this code in one crypto keygen

    for(int i=0; i<16; i++)
    {
    sprintf(Temp, "%.2X", MD5_bytes[i]&0xFF);
    strcat(Buffer, Temp);
    }

    Then I put
    SetDlgItemText(hWnd, IDC_SERIAL, Buffer);

    But the text in IDC_SERIAL is not the MD5 hash
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  7. #7
    Oh, go on then, because I feel for a fellow C/C++ coder. Leave those asm lunatics to their padded cells

    Code:
    #include <Wincrypt.h>
    
    HCRYPTPROV hCrypt = NULL;
    if(!CryptAcquireContext(&hCrypt, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
    {
       //failed
    }
    
    
    HCRYPTHASH hHash;
    if(!CryptCreateHash(hCrypt, CALG_MD5, 0, 0, hHash))
    {
       //failed
    }
    
    char* szHashMe = "Hash this string";
    if(!CryptHashData(hHash, szHashMe, strlen(szHashMe), 0))
    {
       //failed
    }
    
    char* szHashResult = new char[255];
    if(!CryptGetHashParam(hHash, HP_HASHVAL, szHashResult, 255, 0))
    {
       //failed
    }
    
    CryptDestroyHash(hHash);
    CryptReleaseContext(hCrypt, 0);
    Erm, bear in mind I did this in about 5 mins translating neviens code...
    Still here...

  8. #8
    son of Bungo & Belladonna bilbo's Avatar
    Join Date
    Mar 2004
    Location
    Rivendell
    Posts
    310
    Oops, Silver, don't be too sure, you made two errors...

    (1) last argument of CryptCreateHash() must be &hHash, not hHash
    (2) CryptGetHashParam must not be passed 255, but the address of a long containing 255


    ChemicalX, your Buffer doesn't contains ASCII characters, so you need to convert it to a printable form, before passing it to SetDlgItemText().

    Please ignore the text above: that's an error of mine...neviens guess is a good one!

    Regards, bilbo
    Last edited by bilbo; September 14th, 2004 at 09:48.
    Non quia difficilia sunt, non audemus, sed quia non audemus, difficilia sunt.[Seneca, Epistulae Morales 104, 26]

  9. #9
    As far as I understand, this code:

    for(int i=0; i<16; i++)
    {
    sprintf(Temp, "%.2X", MD5_bytes[i]&0xFF);
    strcat(Buffer, Temp);
    }


    converts the hex MD5 value to printable ASCII form.
    Have you cleared a Buffer before 1st strcat?
    Neviens.

  10. #10
    Damn bugs. They're everywhere, and usually in my code.
    Still here...

  11. #11
    ChemicalX
    Guest
    here is an example of what im tring to achieve
    http://cryptokg.cjb.net/ And in the tools section download the Md5 Checker.

    Now ive also downloaded C-Ripper's solution for TMG trial #4. In the keygen, C-Ripper makes a md5 hash and does some other stuff with miracl.h. So i took out all the extra parts with the miracl and made the program display just the md5 hash without any calculations (except for the converting to ascii). But when i compare it with a real hash it is not the same

    I don't know if its the way to display, or maybe if the md5.h is modified
    Take a look for yourself
    I promise that I have read the FAQ and tried to use the Search to answer my question.

  12. #12
    ChemicalX
    Guest
    Sorry all this time its been my fault, i have been using the wrong include. I should have used the md5c.c from RSA but instead ive been using md5.c from some random website.
    Now my program is working fine.

    Thanks for your help
    I promise that I have read the FAQ and tried to use the Search to answer my question.

Similar Threads

  1. anyone know what type of hash this is?
    By twisted in forum RCE Cryptographics
    Replies: 2
    Last Post: November 26th, 2010, 04:57
  2. hash algo help
    By ramin_rad2000 in forum RCE Cryptographics
    Replies: 5
    Last Post: September 7th, 2004, 15:49
  3. REQ: binary calculator
    By yaa in forum Tools of Our Trade (TOT) Messageboard
    Replies: 10
    Last Post: May 3rd, 2004, 04:33
  4. possible to get the string(file) from md5 hash
    By highfly in forum The Newbie Forum
    Replies: 7
    Last Post: April 19th, 2004, 19:09
  5. help me on reversing hash function
    By akimp3 in forum RCE Cryptographics
    Replies: 10
    Last Post: December 19th, 2002, 21:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •