Guest User

Untitled

a guest
Dec 14th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. private String getEncodedPassword(String password) throws NoSuchAlgorithmException {
  2.         MessageDigest md = MessageDigest.getInstance("MD5");
  3.         md.update(password.getBytes());
  4.  
  5.         byte byteData[] = md.digest();
  6.  
  7.         StringBuffer sb = new StringBuffer();
  8.         for (int i = 0; i < byteData.length; i++) {
  9.             sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
  10.         }
  11.  
  12.         StringBuffer hexString = new StringBuffer();
  13.         for (int i = 0; i < byteData.length; i++) {
  14.             String hex = Integer.toHexString(0xff & byteData[i]);
  15.             if (hex.length() == 1) hexString.append('0');
  16.             hexString.append(hex);
  17.         }
  18.         return hexString.toString();
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment