哪位大哥幫忙翻譯成PHP? JAVA不懂, 對方沒有PHP SDK謝謝了.
/** * 簽名演算法 * * @return * @throws Exception */ public static String createSign(String param) throws Exception { StringBuffer result = new StringBuffer(); MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(param.getBytes("UTF-8")); byte[] b = md5.digest(); for(int i=0;i< b.length;++i) { int x = b[i]&0xFF; int h = x>>>4; int l = x&0x0F; result.append((char)(h+((h<10)?'0':'a'-10))); result.append((char)(l+((l<10)?'0':'a'-10))); } return result.toString().substring(8, 24); }
回複內容:
哪位大哥幫忙翻譯成PHP? JAVA不懂, 對方沒有PHP SDK謝謝了.
/** * 簽名演算法 * * @return * @throws Exception */ public static String createSign(String param) throws Exception { StringBuffer result = new StringBuffer(); MessageDigest md5 = MessageDigest.getInstance("MD5"); md5.update(param.getBytes("UTF-8")); byte[] b = md5.digest(); for(int i=0;i< b.length;++i) { int x = b[i]&0xFF; int h = x>>>4; int l = x&0x0F; result.append((char)(h+((h<10)?'0':'a'-10))); result.append((char)(l+((l<10)?'0':'a'-10))); } return result.toString().substring(8, 24); }
function create_sign($src){ return substr(md5($src), 8, 16);}