MD5 di Java

public static String getMD5Hash(String text) throws Exception
{
    byte[] bytesOfMessage = text.getBytes("UTF-8");
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update( bytesOfMessage );
    byte[] md5sum = md.digest();
    BigInteger bigInt = new BigInteger(1, md5sum);
    String MD5Hash = bigInt.toString(16);
    while ( MD5Hash.length() < 32 ) {
        MD5Hash = "0" + MD5Hash;
    }

    return MD5Hash;
}

Komentar

Postingan populer dari blog ini

Batch Script untuk mengcopy file terbaru