|
Aug
24
|
We’ve previously shown how to create an MD5 sum for a file. If you don’t have a file and instead just need an MD5 sum for a byte array then you can achieve it using the following code.
// Data is the byte array we need an MD5 sum for
byte[] data = getDataFromWhereever();
// Get an MD5 implementation of MessageDigest
MessageDigest md = MessageDigest.getInstance("MD5");
// Convert the MD5 byte array to a hex string
String md5 = new BigInteger(1, md.digest(data)).toString(16);



Recent Comments