public static String md5(String stringToHash){
  if (stringToHash != null) {
    try {
      MessageDigest md=MessageDigest.getInstance("MD5");
      byte[] bytes=md.digest(stringToHash.getBytes());
      StringBuilder sb=new StringBuilder(2 * bytes.length);
      for (int i=0; i < bytes.length; i++) {
        int low=(bytes[i] & 0x0f);
        int high=((bytes[i] & 0xf0) >> 4);
        sb.append(Constants.HEXADECIMAL[high]);
        sb.append(Constants.HEXADECIMAL[low]);
      }
      return sb.toString();
    }
 catch (    NoSuchAlgorithmException e) {
      return "";
    }
  }
 else {
    return "";
  }
}

public static String md5 ( String stringToHash ) { if ( stringToHash != null ) { try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; byte [ ] bytes = md . digest ( stringToHash . getBytes ( ) ) ; StringBuilder sb = new StringBuilder ( 2 * bytes . length ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { int low = ( bytes [ i ] & 0x0f ) ; int high = ( ( bytes [ i ] & 0xf0 ) > > 4 ) ; sb . append ( Constants . HEXADECIMAL [ high ] ) ; sb . append ( Constants . HEXADECIMAL [ low ] ) ; } return sb . toString ( ) ; } catch ( NoSuchAlgorithmException e ) { return "" ; } } else { return "" ; } }
convierte un string a hash md5
