1 public static String encode(String str) 2 { 3 String code=null; 4 try { 5 MessageDigest digest=MessageDigest.getInstance("MD5"); 6 code = new String(digest.digest(str.getBytes())); 7 System.out.println(code); 8 } catch (NoSuchAlgorithmException e) { 9 e.printStackTrace(); 10 } 11 return code; 12 }