Couldn't find this very easily (without including a bunch of c-mex files etc) so I thought I'd post it here for future reference. I prefer using java methods to avoid dependencies.
Using java, how to create a MD5 (or SHA1 etc) hash sum of a string?
The trick here is to input an ascii representation of your string (hence, the double(string) call). MessageDigest outputs 16 bytes which represents 32 chars. So we use BigInteger to convert the bytes to that radix.
import java.security.*; import java.math.*;
md = MessageDigest.getInstance('MD5'); hash = md.digest(double('Your string.')); bi = BigInteger(1, hash); char(bi.toString(16))