mp_sig签名一直提示错误
发布于 6 年前 作者 xia29 2117 次浏览 来自 问答
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;
   }
3 回复

“errcode”: 90009,

   “errmsg”: “mp_sig error hint: [m7hsEA05873139]”

错误信息都没有啊。

回到顶部