我也遇到了同样的问题,有没有大佬指点指点
微信小程序支付v3接口生成二次签名paysign,一直提示支付验证失败?public static String getTokenTwo (String appId, String packag) throws IOException, SignatureException, NoSuchAlgorithmException, InvalidKeyException { String nonceStr = getRandomString(32); long timestamp = System.currentTimeMillis() / 1000; String message = buildMessageTwo( appId,timestamp,nonceStr,packag); String signature = sign(message.getBytes("utf-8")); return signature; } private static String buildMessageTwo(String appId, long timestamp, String nonceStr, String packag) { return appId + "\n" + timestamp + "\n" + nonceStr + "\n" + packag + "\n"; } private static String sign(byte[] message) throws NoSuchAlgorithmException, SignatureException, IOException, InvalidKeyException { Signature sign = Signature.getInstance("SHA256withRSA"); //SHA256withRSA PrivateKey privateKey = getPrivateKey("密钥文件地址"); sign.initSign(privateKey); sign.update(message); return Base64.getEncoder().encodeToString(sign.sign()); }
2021-03-12