123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using AnHuiMI.Common;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Variables;
- using GMCrypto.Lib;
- using PTMedicalInsurance.Common;
- namespace PTMedicalInsurance.Helper
- {
- class EncryptHelper
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private string appId = "1HIL9529R00S76430B0A0000E404A442";
- private string appSecret = "1HIL952A300T76430B0A00002E935C4F";
- private string privateKey = "AM6zW7ET7L15vZLz4H53Q9uNoQr83FEfvU0P+uqvdYh4";
- private string publicKey = "BPJ3dKzwOgGf0rA70YU3cUxtASeI2Arg1IOtUtBHVmUuj0XcZq0gkn2RqxMdzMC2gcAd25g+Uxj6l+GvCMTQCXA=";
- public EncryptHelper()
- { }
- public EncryptHelper(string appId,string secret,string prvKey,string pubKey)
- {
- this.appId = appId;
- this.appSecret = secret;
- this.privateKey = prvKey;
- this.publicKey = pubKey;
- }
- public string getSignText(string data)
- {
- return "";
-
-
- }
- public string encrypt(string data,ref string signText)
- {
- string encryptData = "";
- try
- {
- string strData = JsonConvert.SerializeObject(JObject.Parse(data), Newtonsoft.Json.Formatting.None);
- encryptData = SignUtils.encryptMsg(appId, appSecret, privateKey, strData, ref signText);
- return encryptData;
- }
- catch (Exception ex)
- {
- encryptData = ex.Message;
- return encryptData;
- }
- finally
- {
-
- }
- }
- public string sign(string data)
- {
- string encryptData = "";
- try
- {
- encryptData = SignUtils.signSm3WithSm2(appSecret, privateKey, data);
- return encryptData;
- }
- catch (Exception ex)
- {
- encryptData = ex.Message;
- return encryptData;
- }
- finally
- {
-
- }
- }
- public bool verify(JObject signDto, string signData)
- {
- string error = "";
- try
- {
- return SMUtil.verify(signDto, appSecret, publicKey, signData);
- }
- catch (Exception ex)
- {
- error = ex.Message;
- return false;
- }
- finally
- {
-
- }
- }
- public string decrypt(string encryptData)
- {
- string data = "";
- try
- {
- data = SMUtil.decrypt(encryptData, appId, appSecret);
- return data;
- }
- catch (Exception ex)
- {
- data = ex.Message;
- return data;
- }
- finally
- {
-
- }
- }
- }
- }
|