Advertisement
xlrnxnlx

toMD5 - working

Jul 31st, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public String toMd5(String str) {
  2.     try {
  3.         MessageDigest m = MessageDigest.getInstance("MD5");
  4.         m.update(str.getBytes(), 0, str.length());
  5.         BigInteger i = new BigInteger(1,m.digest());
  6.         return String.format("%1$032x", i);        
  7.     } catch (NoSuchAlgorithmException e) {
  8.         e.printStackTrace();
  9.     }
  10.         return null;
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement