Sample code for 30+ languages & platforms
Java

MD5 Hash a String

MD5 hash a string.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    //  This example assumes the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkCrypt2 crypt = new CkCrypt2();

    String content = "The quick brown fox jumps over the lazy dog";

    //  The desired output is a hexidecimal string:
    crypt.put_EncodingMode("hex");

    //  Set the hash algorithm:
    crypt.put_HashAlgorithm("md5");

    String hashStr;
    hashStr = crypt.hashStringENC(content);

    System.out.println(hashStr);

    //  The output is:
    //  9E107D9D372BB6826BD81D3542A419D6
  }
}