Java examples for Security:MD5
get MD5 byte array from String
//package com.java2s; import java.security.MessageDigest; public class Main { public static void main(String[] argv) throws Exception { String input = "java2s.com"; System.out.println(java.util.Arrays.toString(getMD5(input))); }/*from www. j a v a 2s.c om*/ private static byte[] getMD5(String input) { try { byte[] bytesOfMessage = input.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); return md.digest(bytesOfMessage); } catch (Exception e) { return null; } } }