package com.tzy.s.wx.payment;

import com.alibaba.fastjson.JSONObject;

import java.util.UUID;

public class PaymentUtil {


    public static String encode(String mrethod,String url,long timestamp, String jsonStr) throws Exception {
        StringBuffer estr = new StringBuffer();
        estr.append(mrethod).append("\n")
                .append(url).append("\n")
                .append(timestamp).append("\n")
                .append(UUID.randomUUID().toString().replaceAll("-","")).append("\n")
                .append(jsonStr).append("\n");
        String s = estr.toString();
        System.out.println("s>>>"+s);
        byte[] bytes = s.getBytes("utf-8");
        String publickey =
                "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDh9tuY/onKOHRt" +
                "16WcyAECTNiniatyiG0cNgmeFdp6AN13fSbXNCCCiWkehyamtQ47Mk5YPwXj8LGI" +
                "MjK3wT04jas1RE43/77WAi9aWSMOsRWecD/sRBohtRLtqMESOALwxbTTItHkNULC" +
                "oAQkDd8KdzAeVhV8nzDbltkz+rjIzFcMF8LexzY2GH0zzLizUP/8lGAGQ4hJWgTI" +
                "ns4Lj9IgvremRVelmqxPg4gI69NDBXcM3K044w0xqIZMzuKnFjWn2CmEz6tmCjCP" +
                "m00k4Q8eWPj8Fc9xGaEuQpwhEH4+KmZ876bD1znaNSPikiOk33nj9rEg1+phiPD8" +
                "+WKwEje9AgMBAAECggEAOl9tBy7qJYVD/oQw0jmQmSmE5nLYCXRYy2riPSZkFBRZ" +
                "Id8Aw6NBqrcYorxDLdmj3YL3XjCZsvKgyhA9rd6LlCp0ygPlOO4mPF7AINTaC5eP" +
                "gCh7Ouu03HRMeXyYs74odE5+kfRyyENCBckUiMPUlH2Jvqx6TIFLO87SOW1Rgv1a" +
                "SLO3zXFcCVU9VKoIzHzWVVZ3NMCOFYYlAfo4HYtooF8ln+Nb6SNsLQrRuVNHh81G" +
                "yMpoUvN78eSJI4FJma5dGV5Y5yOxr+uquWilMPQtlPLYSmhYdV42i9K3UVd08LRd" +
                "WPzYC5NK0wrGQ98Bql6knFjzOJ8Aceb08ZsQl3JBAQKBgQD25mXb9HPwws3PXLkx" +
                "1H5nY0a10UQ1yTEX3O+KbACmIgOIS+9KlqhbvqGEiLAUYFDCpxqUxk1GKXeh28d0" +
                "W4gkiNTQoNQxerb8f/4tUmzBA9h1WSeE+CDCxjCRVzM+aOvRQYu+MqqLXO/AYDpy" +
                "BrdwjnnS8akUCTFx2ybj1Fz+4QKBgQDqSuxKwed3P63kwuoSrA0xaO8envgz5PQd" +
                "ViYVkWnCe8F5s+YJe3ctz4eT9zDgMjNKIB9n7wjV3C5tWOOq+f4Ktr8WJ2ITUDkA" +
                "/vW5jJL+KAtG3GldC6qxrYSFkiV+XxGNMobDFzfGQS+YNiSuqdr+rHiMv6V90ATk" +
                "dxMme52gXQKBgFh7w59rYS20ssuQ4HICRHbK9mlsoPRhsS1rKZHDGQxw/jEXfZ+O" +
                "lLGkhQAZeHkk92x7NKSC2Oi/LbedK0MBFq55N0O5j7JX10JwoGgftQgLV8TeebJG" +
                "tn73RiqgRKYmNfUdd3ZndAVT/jxEgE2jKJS3CuPVZZHfpY+3SZ222skhAoGARSWj" +
                "o1SjCbDDk7Zq+uPIaQK9P95PBpHV8iqQxuDJw9peeZq8k6PawqxzKRpVVHW8aW4d" +
                "lsEXbHa1RRRs7PMnJOZWcyVgbq7IhCC7SO3SHCyZV2qJtipRUGsTp5BAfJF2TqPQ" +
                "3hcmIN7wOw4PuXTr6ynf0jplj0Irj3oNLthg5wkCgYEAll8pQigUCe2wikNP31zN" +
                "ZtKQpvP8Uzn5Bw6aYzWpJ2zmwnK9TdmU21KQ3iEzEqQTuGCiHI5MC+2+ak9wKidb" +
                "aSWu7dKMcaCvbWG5788R6cxmUuH1rfmC6l49qtVf50TCDlEpfHROGUIlmK2NA26h" +
                "gvIc9gPbGnijIX8Jq6pBJyo=";
        return RSAUtils.signByPrivateKey(bytes, publickey);
    }


}
