public static String encrypt(String message, String encode, boolean toUpperCase) {
    """
	MD5 加密 <br>
	2013-11-4 下午6:33:06
	
	@param message     要加密的内容
	@param encode      message的编码方式
	@param toUpperCase 是否转换成大写
	@return 加密后的信息
    """
        MessageDigest messageDigest = null;

        try {
            messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.reset();
            messageDigest.update(message.getBytes(encode));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        byte[] byteArray = messageDigest.digest();

        StringBuffer md5StrBuff = new StringBuffer();

        for (int i = 0; i < byteArray.length; i++) {
            if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {
                md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));
            } else {
                String hex = Integer.toHexString(0xFF & byteArray[i]);
                if (toUpperCase) {
                    hex = hex.toUpperCase();
                }
                md5StrBuff.append(hex);
            }
        }
        return md5StrBuff.toString();
    }
public static String encrypt(String message, String encode, boolean toUpperCase) {
        MessageDigest messageDigest = null;

        try {
            messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.reset();
            messageDigest.update(message.getBytes(encode));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        byte[] byteArray = messageDigest.digest();

        StringBuffer md5StrBuff = new StringBuffer();

        for (int i = 0; i < byteArray.length; i++) {
            if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) {
                md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i]));
            } else {
                String hex = Integer.toHexString(0xFF & byteArray[i]);
                if (toUpperCase) {
                    hex = hex.toUpperCase();
                }
                md5StrBuff.append(hex);
            }
        }
        return md5StrBuff.toString();
    }
public static String encrypt ( String message , String encode , boolean toUpperCase ) { MessageDigest messageDigest = null ; try { messageDigest = MessageDigest . getInstance ( "MD5" ) ; messageDigest . reset ( ) ; messageDigest . update ( message . getBytes ( encode ) ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } byte [ ] byteArray = messageDigest . digest ( ) ; StringBuffer md5StrBuff = new StringBuffer ( ) ; for ( int i = 0 ; i < byteArray . length ; i ++ ) { if ( Integer . toHexString ( 0xFF & byteArray [ i ] ) . length ( ) == 1 ) { md5StrBuff . append ( "0" ) . append ( Integer . toHexString ( 0xFF & byteArray [ i ] ) ) ; } else { String hex = Integer . toHexString ( 0xFF & byteArray [ i ] ) ; if ( toUpperCase ) { hex = hex . toUpperCase ( ) ; } md5StrBuff . append ( hex ) ; } } return md5StrBuff . toString ( ) ; }
MD5 加密 <br>
2013-11-4 下午6:33:06

@param message     要加密的内容
@param encode      message的编码方式
@param toUpperCase 是否转换成大写
@return 加密后的信息
MD5 加密 <br > 2013 - 11 - 4 下午6 : 33 : 06