Saturday, November 7, 2015

Creating an MD5 Hash From a String in Java

Using the MessageDigest Class, here's code to create an MD5 Hash of a String:


public static String makeAuthKey(String k) {
    MessageDigest hasher = MessageDigest.getInstance("MD5");
    byte[] kbh = hasher.digest(kb);
    String bs = new BigInteger(1,kbh).toString(16);
    return bs;
}


0 comments: