Does anyone have any examples of the MD5 algorithm for a microcontroller (preferably an 8-bit one)? Our project is going to use a Microchip PIC18 series device.
If you are looking for a C implementation, the Microchip TCP/IP stack has an implementation of MD5 in the Hashes.c file.
Here's the MD5 implementation from the EtherNut (AVR based)
I would stick with a known reputable implementation of MD5, and stay away from libraries you find from 3rd-party vendors. The original RFC 1321 which described MD5 has a sample C implementation.
Reminder: the known weaknesses for MD5 are collision attacks, and not preimage attacks, so it is suitable for some cryptographic applications but not others. If you don't know the difference you shouldn't be using it, but don't discard it altogether. See http://www.vpnc.org/hash.html.
from the wikipedia page on MD5:
... it has been shown that MD5 is not collision resistant as such, MD5 is not suitable for applications like SSL certificates or digital signatures that rely on this property.
and from the SSL researchers on the same page:
We also hope that use of MD5 in other applications will be reconsidered as well.
I understand that you probably don't want to hear this, but do you really need MD5? It shouldn't be used for cryptographic purposes as it is too insecure (and there are boatloads of rainbow tables available). If you are looking for something to just validate data, look into CRC (code here) which is computationally cheaper. If you are using it for cryptographic purposes though, then may I suggest moving to SHA? The only problem is that most cryptographically secure algorithms do not run particularly well on microcontrollers. I know it may seem like MD5 is "good enough", but the engineering way is to err on the side of caution.