如题。微信开放平台支付加密类代码如下


    // 微信支付 md5认证
    	public static  String getMd5WeixinToPay(String str) {
    		MessageDigest md;
    		try {
    			md = MessageDigest.getInstance("MD5");
    			md.reset();
    			md.update(str.getBytes("UTF-8"));
    			return  byteToStr(md.digest()).toUpperCase();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		return "";
    	}
    /**
    	* 将字节数组转换为十六进制字符串
    	* 
    	* @param byteArray
    	* @return
    	*/
    	public static String byteToStr(byte[] byteArray) {
    		 String strDigest = "";
    		 for (int i = 0; i < byteArray.length; i++) {
    			 strDigest += byteToHexStr(byteArray[i]);
    		 }
    	 return strDigest;
    	}
    /**
    	* 将字节转换为十六进制字符串
    	* 
    	* @param btyes
    	* @return
    	*/
    	public static String byteToHexStr(byte bytes) {
    		 char[] Digit = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
    		 char[] tempArr = new char[2];
    		 tempArr[0] = Digit[(bytes >>> 4) & 0X0F];
    		 tempArr[1] = Digit[bytes & 0X0F];
    		 String s = new String(tempArr);
    		 return s;
    	}
    源地址 :http://blog.xuahua.com/articles/2016/07/13/1468399623674.html


    联系QQ:343886028 --加QQ群 145315854