數據加簽加密

  /**
     * RSA方式加簽
     * 
     * @param custId
     * @param forEncryptionStr
     * @param charset
     * @return
     * @throws Exception 
     */
    public static String encryptByRSA(String forEncryptionStr) throws Exception {
        SecureLink sl = new SecureLink();
        int result = sl.SignMsg(RECV_MER_ID, MER_PRI_KEY_PATH, forEncryptionStr);
        if (result < 0) {
            // 打印日誌 
            throw new Exception();
        }
        return sl.getChkValue();
    }
/**
* 解籤
* @param forEncryptionStr
* @param chkValue
* @return
* @throws Exception
*/
    public static boolean verifyByRSA(String forEncryptionStr, String chkValue)
                                                                                       throws Exception {
        try {
            int verifySignResult = new SecureLink().VeriSignMsg(MER_PUB_KEY_PATH, forEncryptionStr, chkValue);
            return verifySignResult == RAS_VERIFY_SIGN_SUCCESS;
        } catch (Exception e) {
            // 打印日誌
            throw new Exception();
        }
    }
    /**
     * 
    * @Title: doPost 
    * @Description: TODO(匯付接口 後臺提交) 
    * @param @param params 請求參數
    * @param @return
    * @param @throws ClientProtocolException
    * @param @throws IOException  參數說明 
    * @return String    返回類型 
    * @author cjm
    * @throws
     */
    // 若是關注性能問題能夠考慮使用HttpClientConnectionManager
    public static String doPost(Map<String, String> params) throws ClientProtocolException, IOException{
    String result = null;
    HttpPost httpPost = new HttpPost(HttpClientHandler.HTTP_HOST);
    CloseableHttpClient httpclient = HttpClients.createDefault();
    if (params != null)
    {
    UrlEncodedFormEntity formEntiry = HttpClientHandler.buildUrlEncodedFormEntity(params);
    httpPost.setEntity(formEntiry);
    CloseableHttpResponse response = httpclient.execute(httpPost);
    try
    {
    HttpEntity entity = response.getEntity();
    if (response.getStatusLine().getReasonPhrase().equals("OK") && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
    result = EntityUtils.toString(entity, "UTF-8");
       EntityUtils.consume(entity);
    } finally
    {
    response.close();
    }
    }
    return result;
    }性能

<div class="article_title">   
<a href="http://linyi.changtu.com/">臨沂汽車總站</a>
</div>ui

相關文章
相關標籤/搜索