mp_sig签名一直提示错误
private static String getSign(Map<String,String> nutMap, String urlData, String session_key) {
Set<String> set1 = nutMap.keySet();
String[] arrayToSort1 = set1.toArray(new String[set1.size()]);
Arrays.sort(arrayToSort1,String.CASE_INSENSITIVE_ORDER);
StringBuilder stringBuilder1 = new StringBuilder("");
for (String str : arrayToSort1) {
if (stringBuilder1.toString().equals("")) {
stringBuilder1.append(str + "=" + nutMap.get(str));
} else {
stringBuilder1.append("&" + str + "=" + nutMap.get(str));
}
}
log.info("buy|stringBuilder1=" + stringBuilder1.toString());
String temp = "";
try {
stringBuilder1.append(urlData);
// log.info("buy|stringBuilder1=" + stringBuilder1.toString());
temp = SnsSigCheck.encodeUrl(stringBuilder1.toString());
log.info("buy|aaaaaaaaaa=" + stringBuilder1.toString().equals(temp));
}catch (Exception e){
}
String mp_sig = null;//
try {
Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(session_key.getBytes("UTF-8"), mac.getAlgorithm());
mac.init(secretKey);
byte[] hash = mac.doFinal(temp.getBytes("UTF-8"));
mp_sig = new String(Base64Coder.encode(hash));
}catch (Exception e){
Logs.get().error("=========e="+ Lang.getStackTrace(e));
}
return mp_sig;
}