65.9K
CodeProject is changing. Read more.
Home

MD5 Hash Calculator Pocket PC 2003/Windows CE 4.x

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.09/5 (5 votes)

May 17, 2005

CPOL

1 min read

viewsIcon

53554

downloadIcon

239

A small tool for calculating a MD5 hash.

Introduction

Background: I experienced some problems with my SD memory card in my HP IPAQ 1940. My GPS program had a lot of bugs I thought. Because it couldn't handle large maps. After some testing, I figured out that 64 MB was the magic limit. The tool I used to test was MD5 Hashing.

My simple method:

  • Create a large file (100 MB) on the SD card.
  • Calculate MD5 on the PC (SD card in card reader).
  • Insert SD card into IPAQ.
  • Calculate MD5 on the IPAQ.
  • Check if same. If not decrease size by half, if the hash is the same increase the file by 50%.

This gave the result that it was something goofy around 64 MB files.

After that I checked the obvious (thanks Rob). If there are any updates on the HP website for my IPAQ. And there was. So if you are having any problems with large (>64 MB) files on your IPAQ 1940 (or other models), check for updates at the HP website. The update for 1940 can be downloaded here.

Anyway, problem found and solved. I thought you might find it useful to have a MD5 Hasher for Pocket PC, so here it is. Parts of the code is (c) RSA Data Security, Inc.

Code snippet:

  MD5_CTX m_md5;
  CString tempHash = "";

    if (md5file(m_strFile.GetBuffer(MAX_PATH), 0, &m_md5))
    {
        for (int i = 0; i < 16; i++)
        {
            char tmp[3];
            _itoa(m_md5.digest[i], tmp, 16);
            if (strlen(tmp) == 1)
            {
                tmp[1] = tmp[0];
                tmp[0] = '0';
                tmp[2] = '\0';
            }
            tempHash += tmp;
        }
    }

The result is delivered in human readable format in tempHash.

Drop me an e-mail with comments or questions. To see what I should do instead of debugging SD-cards, have a look at www.freefloat.com.