Java コード
public static String getMD5(String orgin, String charset) { if (charset == null) charset = "utf-8"; String result = null; try { MessageDigest md = MessageDigest.getInstance("MD5"); result = byte2hex(md.digest(orgin.getBytes(charset))); } catch (Exception e) { throw new java.lang.RuntimeException("sign error !", e); } return result;}private static String byte2hex(byte[] b){ StringBuffer hs = new StringBuffer(); String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); if (stmp.length() == 1) hs.append("0").append(stmp); else hs.append(stmp); } return hs.toString();}public static String encode(byte[] srcContent) { if(srcContent == null) { return null; } //的实现会每76个字符后面增加一个回车,需要删除。 return new BASE64Encoder().encode(srcContent).replace("\r\n", "");}String data = "helloword";String secret = "123456";String md5Value = Md5Util.getMD5(data + secret);String reSign = Base64Util.encode(md5Value.getBytes("utf-8")); //结果reSign=Y2UyMTllODgzNTVmMmYzYzI3NTEwOWM0OWY1YTVmMjU=
PHP コード
$reSign = base64_encode(md5($data.$secret))