Advertisement
ridjis

MD5

Sep 5th, 2016
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class Utils {
  2.    
  3.     public static String MD5(String md5) {
  4.         try {
  5.             java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
  6.             byte[] array = md.digest(md5.getBytes());
  7.             StringBuffer sb = new StringBuffer();
  8.             for (int i = 0; i < array.length; ++i)
  9.                 sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
  10.                
  11.             return sb.toString();
  12.         } catch (java.security.NoSuchAlgorithmException e) { }
  13.         return null;
  14.     }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement