SHARE
TWEET

CryptWithMD5

a guest Jul 16th, 2016 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package br.com.thiengo.thiengocalopsitafbexample.domain.util;
  2.  
  3. import android.util.Log;
  4.  
  5. import java.security.MessageDigest;
  6. import java.security.NoSuchAlgorithmException;
  7. import java.util.logging.Level;
  8.  
  9. // FONTE: http://stackoverflow.com/a/14201817/2578331
  10.  
  11. public class CryptWithMD5 {
  12.     private static MessageDigest md;
  13.  
  14.     public static String cryptWithMD5(String pass){
  15.         try {
  16.             md = MessageDigest.getInstance("MD5");
  17.             byte[] passBytes = pass.getBytes();
  18.             md.reset();
  19.             byte[] digested = md.digest(passBytes);
  20.             StringBuffer sb = new StringBuffer();
  21.             for(int i=0;i<digested.length;i++){
  22.                 sb.append(Integer.toHexString(0xff & digested[i]));
  23.             }
  24.             return sb.toString();
  25.         } catch (NoSuchAlgorithmException ex) {
  26.             Log.e("LOG", Level.SEVERE+" - "+ex);
  27.         }
  28.         return null;
  29.  
  30.  
  31.     }
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top