微信小程序,重置登录 ResetUserSessionKey接口,session_key加密生成签名,一直报无效,签名方法如下:
public static String hmacSHA256(String secret, String message) throws Exception {
String hash = "";
Mac hmacSha256 = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
hmacSha256.init(secret_key);
byte[] bytes = hmacSha256.doFinal(message.getBytes());
hash = byteArrayToHexString(bytes);
return hash;
}
调用
HmacSHA256Util.hmacSHA256(wxResetSessionKeyInDTO.getSessionKey(),"")