public string GetEncryptPassword(string password) { string result = string.Empty; IAsymmetricEncryptionService IasymmetricEncryptionService = Sm2Service.Instance; try { MiicCryptoKeyPair keyPair = IasymmetricEncryptionService.CreateKeyPair(); result = IasymmetricEncryptionService.Encrypt(keyPair.PublicKey, password); Context.Session["PrivateKey"] = keyPair.PrivateKey; } catch (Exception ex) { Config.IlogicLogService.Write(new LogicLog() { AppName = Config.AppName, ClassName = ClassName, NamespaceName = NamespaceName, MethodName = MethodBase.GetCurrentMethod().Name, Message = ex.Message, Oper = Config.Oper }); } return(result); }
public string GetSm3Digest(string id) { IDigestEncryptionService Iservice = Miic.Cryptographic.SM3.Sm3Service.Instance; IAsymmetricEncryptionService IasymmetricEncryptionService = Sm2Service.Instance; string result = Iservice.Encrypt(id); return(result); }
private string getMD5bySM2(string sm2Password) { string result = string.Empty; try { IAsymmetricEncryptionService IasymmetricEncryptionService = Sm2Service.Instance; result = IasymmetricEncryptionService.Decrypt(HttpContext.Current.Session["PrivateKey"].ToString(), sm2Password); } catch (Exception ex) { Config.IlogicLogService.Write(new LogicLog() { AppName = Config.AppName, ClassName = ClassName, NamespaceName = NamespaceName, MethodName = MethodBase.GetCurrentMethod().Name, Message = ex.Message, Oper = Config.Oper }); } return(result); }