JAVA微信支付分生成签名

JAVA微信支付分生成签名

//生成签名的方法:

public class CreateSigner {

public static Map getToken(String method, HttpUrl url, String body) throws IOException, SignatureException, NoSuchAlgorithmException, InvalidKeyException {
    String nonceStr = String.valueOf(UUID.randomUUID()).replace("-","");
    long timestamp = System.currentTimeMillis() / 1000;
    String message = buildMessage(method, url, timestamp, nonceStr, body);
    String signature = sign(message.getBytes(StandardCharsets.UTF_8));
    Map map=new HashMap();
    map.put("sign","mchid=\""+BasicInfo.XIAO_MchId+"\","
            + "nonce_str=\""+nonceStr+"\","
            + "timestamp=\""+timestamp+"\","
            + "serial_no=\""+BasicInfo.XIAO_mchSerialNo+"\&

你可能感兴趣的:(Java实战,java,spring)