public static string EncryptText(string text, string passwordPhrase) { var aesEncrypted = AesEncrypt.EncryptText(text, passwordPhrase); var desEncrypted = DesEncrypt.EncryptString(aesEncrypted, passwordPhrase); return(desEncrypted); }
public IHttpActionResult Create(AppViewModel model) { var entity = model.ToModel(); entity.a_time = DateTime.Now; entity.a_state = 1; entity.a_rid = 0; entity.a_key = ""; entity.a_secretkey = ""; var a = _iAppService.Insert(entity); DataSourceForm dataSourceForm = new DataSourceForm(); if (a > 0) { entity.a_key = DesEncrypt.Encrypt(entity.a_user_id + ";" + a + ";" + DateTime.Now.ToString("yyyyMMddssmmfff")); entity.a_secretkey = DesEncrypt.Encrypt(a + ";" + entity.a_key + ";" + DateTime.Now.ToString("yyyyMMddssmmfff")); entity.a_id = a; if (_iAppService.Update(entity)) { dataSourceForm.IsSuccess = true; dataSourceForm.Message = "添加成功!"; _logFactory.Logger.CreateLog("新增应用", entity); } } else { dataSourceForm.IsSuccess = false; dataSourceForm.Message = "添加失败!"; } return(Ok(dataSourceForm)); }
/// <summary> /// 页面加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } //按钮权限 btnSubmit.Visible = ActionValidator("SystemSettingAdd"); // 机器码 txtMachineCode.Text = HaikanAuthorization.GetPcCode(); // 授权码 var authorizationCode = ConfigHelper.GetConfigString("AuthorizationCode"); txtAuthorizationCode.Text = authorizationCode; // 到期时间 if (string.IsNullOrEmpty(authorizationCode)) { return; } var code = DesEncrypt.Decrypt(authorizationCode); DateTime stopDateTime = Convert.ToDateTime(code.Split('|')[1]); labStopDateTime.Text = stopDateTime.ToString(CultureInfo.InvariantCulture); if (stopDateTime < DateTime.Now) { labStopDateTime.Text += "已经到期!请联系客服人员进行授权更新!"; } }
public State VerifyCode(string token, string myCode) { try { var now = (long)UnixEpoch.GetSecondsSince(timeProvider.GetNow()); var payload = jwtDecoder.DecodeToObject <Payload>(token, secretBytes, true); var realCode = DesEncrypt.Decrypt(payload.Code, secret); if (realCode.ToUpper() == myCode.ToUpper()) { return(State.OK); } else { return(State.WrongCode); } } catch (SignatureVerificationException e) { if (e.Message == "Token has expired.") { return(State.Expired); } return(State.Invalid); } catch (Exception e) { return(State.Invalid); } }
public JsonResult Validate(string userId, string password) { var user = _userMasterService.GetCachedModel(userId); if (user == null) { return(Json(new ResultInfo() { ErrorNo = -1, ErrorMsg = ResMessage.AccountNotExist })); } if (user.Password != DesEncrypt.Encrypt(password)) { return(Json(new ResultInfo() { ErrorNo = -1, ErrorMsg = ResMessage.AccountNotExist })); } return(Json(new ResultInfo() { ErrorNo = 0, ErrorMsg = "" })); }
/// <summary> /// 用户登录验证 /// </summary> /// <param name="model">用户视图实体类</param> /// <param name="inputPassword">用户输入的密码</param> /// <returns></returns> public static ValidateResponseModel LoginValidator(this LocalUserViewModel model, string inputPassword, string clientId) { var response = ValidateResponseModelFactory.Instance; response.IsValid = true; if (model == null) { response.Message = "登录名不存在"; return(response); } if (model.State == 0) { response.Message = "用户已被锁定"; } //TODO:处理密码 if (DesEncrypt.Encrypt(inputPassword) != model.Password) { response.Message = "密码不正确"; } //if (model.ClientId != clientId) //{ // response.Message = "无效的客户端应用ID"; //} if (response.Message.Length > 0) { response.IsValid = false; } return(response); }
public async Task <DataAPIResult <UserInfoDTO> > Add(UserInfo user) { var result = new DataAPIResult <UserInfoDTO> { data = new UserInfoDTO() }; if (user == null) { result.Fail("数据不能为空"); return(result); } try { user.CreateTime = DateTime.Now; user.GUID = Guid.NewGuid().ToString(); user.PassWord = DesEncrypt.Encrypt(user.PassWord); //user.PassWord = MD5Encrypt.Encrypt(user.PassWord); await db.UserInfo.AddAsync(user); await db.SaveChangesAsync(); var userInfo = await db.UserInfo.Where(a => a.GUID == user.GUID).FirstAsync(); result.data = mapper.Map <UserInfoDTO>(userInfo); result.Success(); } catch (Exception ex) { log.LogError(ex.Message); result.Fail(ex.Message); } return(result); }
public void SubmitForm(AppUser userEntity, string roleIds) { if (userEntity.Id == 0) { userEntity.Create(); string userPassword = "******";//默认密码 userEntity.UserSecretkey = Md5Helper.Md5(Utils.CreateNo(), 16).ToLower(); userEntity.LoginPassword = Md5Helper.Md5(DesEncrypt.Encrypt(Md5Helper.Md5(userPassword, 32).ToLower(), userEntity.UserSecretkey).ToLower(), 32).ToLower(); userEntity.LoginCount = 0; //新增时配置角色 if (roleIds.IsNotNullOrEmpty()) { foreach (string id in roleIds.Split(',')) { int.TryParse(id, out int result); if (result == 0) { continue; } AppUserRole userRoleEntity = new AppUserRole { RoleId = result }; userEntity.UserRoles.Add(userRoleEntity); } } this.Insert(userEntity); } else { using (var db = new RepositoryBase().BeginTrans()) { userEntity.Modify(userEntity.Id); string[] modifystrs = { "LoginName", "StatusCode", "Email", "NickName", "LastModifyUserId", "LastModifyTime" }; this.Update(userEntity, modifystrs); db.Delete <AppUserRole>(u => u.UserId == userEntity.Id); if (roleIds.IsNotNullOrEmpty()) { foreach (string id in roleIds.Split(',')) { int.TryParse(id, out int result); if (result == 0) { continue; } AppUserRole userRoleEntity = new AppUserRole { RoleId = result, UserId = (int)userEntity.Id }; db.Insert(userRoleEntity); } } db.Commit(); } } }
public ActionResult CheckLogin(string username, string password, string code) { LogBaseEntity logBaseEntity = new LogBaseEntity(); logBaseEntity.F_ModuleName = "系统登录"; logBaseEntity.F_Type = DbLogType.Login.ToString(); try { if (Session["nfine_session_verifycode"].IsEmpty() || Md5.md5(code.ToLower(), 16) != Session["nfine_session_verifycode"].ToString()) { throw new Exception("验证码错误,请重新输入"); } var userBaseEntity = new UserService().CheckLogin(username, password); if (userBaseEntity != null) { OperatorModel operatorModel = new OperatorModel(); operatorModel.UserId = userBaseEntity.F_Id; operatorModel.UserCode = userBaseEntity.F_Account; operatorModel.UserName = userBaseEntity.F_RealName; operatorModel.CompanyId = userBaseEntity.F_OrganizeId; operatorModel.DepartmentId = userBaseEntity.F_DepartmentId; operatorModel.RoleId = userBaseEntity.F_RoleId; operatorModel.LoginIPAddress = Net.Ip; operatorModel.LoginIPAddressName = Net.GetLocation(operatorModel.LoginIPAddress); operatorModel.LoginTime = DateTime.Now; operatorModel.LoginToken = DesEncrypt.Encrypt(Guid.NewGuid().ToString()); if (userBaseEntity.F_Account == "admin") { operatorModel.IsSystem = true; } else { operatorModel.IsSystem = false; } OperatorProvider.Provider.AddCurrent(operatorModel); logBaseEntity.F_Account = userBaseEntity.F_Account; logBaseEntity.F_NickName = userBaseEntity.F_RealName; logBaseEntity.F_Result = true; logBaseEntity.F_Description = "登录成功"; new LogService().WriteDbLog(logBaseEntity); } return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功。" }.ToJson())); } catch (Exception ex) { logBaseEntity.F_Account = username; logBaseEntity.F_NickName = username; logBaseEntity.F_Result = false; logBaseEntity.F_Description = "登录失败," + ex.Message; new LogService().WriteDbLog(logBaseEntity); return(Content(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }.ToJson())); } }
public static string Encrypt(string pwd) { if (string.IsNullOrWhiteSpace(pwd)) { return(string.Empty); } return(Md5.md5(DesEncrypt.Encrypt(Md5.md5(pwd, 32), Settings.UserSecretkey).ToLower(), 32).ToLower()); }
public void ResetPassword(AppUser userEntity, string userPassword) { userEntity.UserSecretkey = Md5Helper.Md5(Utils.CreateNo(), 16).ToLower(); userEntity.LoginPassword = Md5Helper.Md5(DesEncrypt.Encrypt(Md5Helper.Md5(userPassword, 32).ToLower(), userEntity.UserSecretkey).ToLower(), 32).ToLower(); string[] modifstr = { "UserSecretkey", "LoginPassword", }; this.Update(userEntity, modifstr); }
public (string token, byte[] image) GenerateCode() { var code = Utils.RndEnNum(4); var image = securityCodeHelper.GetEnDigitalCodeByte(code); var token = jwtEncoder.Encode(new Payload { Code = DesEncrypt.Encrypt(code, secret), ExpiredAt = (long)UnixEpoch.GetSecondsSince(timeProvider.GetNow().AddMinutes(10)) }, secretBytes); return(token, image); }
/// <summary> /// 读cookie值 /// </summary> /// <param name="strName">名称</param> /// <returns>cookie值</returns> public static string GetValue(string strName) { string cookievalue = CookieHelper.GetValue(strName); if (string.IsNullOrEmpty(cookievalue)) { return(string.Empty); } return(DesEncrypt.Decrypt(cookievalue, DesEncryptConfig.CookieValueKey)); }
public static string DecryptText(string text, string passwordPhrase) { var desDecrypted = DesEncrypt.DecryptString(text, passwordPhrase); //Remove pad bytes... desDecrypted = desDecrypted.Replace("\0", string.Empty); var aesDecrypted = AesEncrypt.DecryptText(desDecrypted, passwordPhrase); return(aesDecrypted); }
public void RevisePassword(string userPassword, string keyValue) { UserLogOnBaseEntity userLogOnBaseEntity = new UserLogOnBaseEntity { F_Id = keyValue, F_UserSecretkey = Md5.md5(Common.Common.CreateNo(), 16).ToLower() }; userLogOnBaseEntity.F_UserPassword = Md5.md5(DesEncrypt.Encrypt(Md5.md5(userPassword, 32).ToLower(), userLogOnBaseEntity.F_UserSecretkey).ToLower(), 32).ToLower(); service.Update(userLogOnBaseEntity); }
public JsonResult CheckRight(string userId, string programId) { if(_privilegeService.CheckRight(userId, int.Parse(DesEncrypt.Decrypt(programId)))) { return Json(new ResultInfo() { ErrorNo = 0, ErrorMsg = "" }); } else { return Json(new ResultInfo() { ErrorNo = -1, ErrorMsg = ResMessage.ValidNotThrough }); } }
public void AddCurrent(OnlineUser operatorModel) { if (LoginProvider == "Cookie") { WebHelper.WriteCookie(OnlineUserKey, DesEncrypt.Encrypt(operatorModel.ToJson()), 60); } else { WebHelper.WriteSession(OnlineUserKey, DesEncrypt.Encrypt(operatorModel.ToJson())); } }
/// <summary> /// 读取Cookie某个对象的Value值,返回Value值,如果对象本就不存在,则返回null /// </summary> /// <param name="CookiesName">Cookie对象名称</param> /// <returns>返回对象的Value值,返回Value值,如果对象本就不存在,则返回null</returns> public static string GetCookies(string CookiesName) { if (HttpContext.Current.User == null || HttpContext.Current.Request.Cookies[CookiesName] == null) { return(null); } else { return(DesEncrypt.Decrypt(HttpContext.Current.Request.Cookies[CookiesName].Value)); } }
/// <summary> /// 添加用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public UserContract AddUser(UserContract user) { user.UserId = Guid.NewGuid(); var entity = user.MapTo <UserEntity>(); entity.CreateTime = DateTime.Now; entity.Secretkey = SecurityHelper.GetSha256Hash(WatchHelper.CreateNo(), 16).ToLower(); entity.Password = SecurityHelper.GetSha256Hash(DesEncrypt.Encrypt(SecurityHelper.GetSha256Hash(user.Password, 32).ToLower(), entity.Secretkey).ToLower(), 32).ToLower(); this._db.User.Add(entity); this._db.SaveChanges(); return(user); }
public void AddCurrent(OperatorModel operatorModel) { if (LoginProvider == "Cookie") { WebHelper.WriteCookie(LoginUserKey, DesEncrypt.Encrypt(operatorModel.ToJson()), 60); } else { WebHelper.WriteSession(LoginUserKey, DesEncrypt.Encrypt(operatorModel.ToJson())); } WebHelper.WriteCookie("nfine_mac", Md5.md5(Net.Net.GetMacByNetworkInterface().ToJson(), 32)); //WebHelper.WriteCookie("nfine_licence", Licence.GetLicence()); }
/// <summary> /// 得到用户权限 /// </summary> /// <param name="programID">程序编号</param> /// <returns></returns> /// <remarks></remarks> public static string GetButton(RoleUser roleUser, string programID) { var bllButton = new ButtonService(); StringBuilder strInner = new StringBuilder(); strInner.Append(" INNER JOIN dbo.tbLOG_Program_Button PB ON PB.Button_ID = tbLOG_Button.Button_ID "); strInner.Append(" INNER JOIN dbo.tbLOG_Privilege P ON P.Access_Value = PB.Program_Button_ID "); StringBuilder strWhere = new StringBuilder(); strWhere.Append("Status_Flag = 0 AND PB.Program_ID = "); strWhere.Append(DesEncrypt.Decrypt(programID)); strWhere.Append(" AND P.Access_Master = 2 AND ( ( P.Privilege_Master = 1 AND P.Privilege_Value = '"); strWhere.Append(roleUser.RoleID); strWhere.Append("' ) OR ( P.Privilege_Master = 2 AND P.Privilege_Value = '"); strWhere.Append(roleUser.UserID.ToUpper()); strWhere.Append("' ) ) AND GETDATE() >= P.Valid_From AND GETDATE() <= P.Valid_Until group by [Button_Name] ,[Button_Text] ,[Button_Class] ,[Button_Script] ,[Button_Data_Options] ,[Button_Href],Priority ORDER BY Priority"); DataTable dt = bllButton.GetList(strWhere.ToString(), "[Button_Name] ,[Button_Text] ,[Button_Class] ,[Button_Script] ,[Button_Data_Options] ,[Button_Href],min(P.Operation_ID) Operation_ID", strInner.ToString()).Tables[0]; StringBuilder sb = new StringBuilder(); for (int i = 0; i <= dt.Rows.Count - 1; i++) { if (Convert.ToInt32(dt.Rows[i]["Operation_ID"]) == 3) { continue; } sb.Append("<td><a href=\""); sb.Append(dt.Rows[i]["Button_Href"]); sb.Append("\" class=\""); sb.Append(dt.Rows[i]["Button_Class"]); sb.Append("\" id=\""); sb.Append(dt.Rows[i]["Button_Name"]); sb.Append("\" data-options=\""); sb.Append(dt.Rows[i]["Button_Data_Options"]); if (Convert.ToInt32(dt.Rows[i]["Operation_ID"]) == 2) { sb.Append(",disabled:true\""); } else { sb.Append("\""); } sb.Append(" onclick=\""); sb.Append(dt.Rows[i]["Button_Script"]); sb.Append("\" >"); sb.Append(dt.Rows[i]["Button_Text"]); sb.Append("</a></td>"); sb.Append("<td><div class=\"datagrid-btn-separator\"></div></td>"); } return(sb.ToString()); }
public OnlineUser GetCurrent() { OnlineUser operatorModel = new OnlineUser(); if (LoginProvider == "Cookie") { operatorModel = DesEncrypt.Decrypt(WebHelper.GetCookie(OnlineUserKey).ToString()).ToObject <OnlineUser>(); } else { operatorModel = DesEncrypt.Decrypt(WebHelper.GetSession(OnlineUserKey)?.ToString()).ToObject <OnlineUser>(); } return(operatorModel); }
public OperatorModel GetCurrent() { OperatorModel operatorModel = new OperatorModel(); if (LoginProvider == "Cookie") { operatorModel = DesEncrypt.Decrypt(WebHelper.GetCookie(LoginUserKey).ToString()).ToObject <OperatorModel>(); } else { operatorModel = DesEncrypt.Decrypt(WebHelper.GetSession(LoginUserKey).ToString()).ToObject <OperatorModel>(); } return(operatorModel); }
public OnlineUser Login(UserLoginDto dto) { //if (!SecurityCodeService.IsValid(dto.Token, dto.SecurityCode)) // throw new Exception("错误:图形验证码错误!"); if (string.IsNullOrEmpty(dto.AccountName)) { throw new Exception("账号为空!"); } if (string.IsNullOrEmpty(dto.Password)) { throw new Exception("密码为空!"); } try { var user = CheckLogin(dto.AccountName, dto.Password); if (user != null) { OnlineUser onlineUser = new OnlineUser { UserId = user.Id, AccountName = user.AccountName, UserName = user.RealName, NickName = user.NickName, LoginIPAddress = Net.Ip }; onlineUser.LoginIPAddressName = Net.GetLocation(onlineUser.LoginIPAddress); onlineUser.LoginTime = DateTime.Now; onlineUser.LoginToken = DesEncrypt.Encrypt(Guid.NewGuid().ToString()); if (user.AccountName == "admin") { onlineUser.IsSystem = true; } else { onlineUser.IsSystem = false; } OnlineUserProvider.Provider.AddCurrent(onlineUser); return(onlineUser); } throw new Exception("用户不存在!"); } catch (Exception ex) { throw ex; } }
/// <summary> /// 检查用户 /// </summary> /// <param name="account"></param> /// <param name="password"></param> /// <returns></returns> public UserContract CheckUser(string account, string password) { var user = this._db.User.FirstOrDefault(e => e.UserAccount == account); if (user != null) { string encryPassword = SecurityHelper.GetSha256Hash(DesEncrypt.Encrypt(SecurityHelper.GetSha256Hash(password, 32).ToLower(), user.Secretkey).ToLower(), 32).ToLower(); if (encryPassword == user.Password) { return(user.MapTo <UserContract>()); } } return(null); }
public ActionResult ResetPwd(string newPwd, string loginPassword = "") { int userId = (int)Op.CurrentUser.UserId; if (newPwd.IsNullOrEmpty()) { return(Error("新密码不能为空")); } AppUser userEntity = _appUserRepository.FindEntity(userId); if (userEntity != null) { //当旧密码为空时,直接重置 if (userEntity.LoginPassword.IsNullOrEmpty()) { _appUserRepository.ResetPassword(userEntity, newPwd); return(Success("您的密码已经设置成功,请牢记你的密码噢!")); } else { if (loginPassword.IsNullOrEmpty()) { return(Error("旧密码不能为空")); } if (userEntity.UserSecretkey.IsNullOrEmpty()) { return(Error("用户密钥丢失,请联系管理员重置密码")); } string dbPwd = Md5Helper.Md5(DesEncrypt.Encrypt(loginPassword.ToLower(), userEntity.UserSecretkey).ToLower(), 32).ToLower(); if (userEntity.LoginPassword.Equals(dbPwd)) { _appUserRepository.ResetPassword(userEntity, newPwd); return(Success("您的密码已经设置成功,请牢记你的密码噢!")); } else { return(Error("你的旧密码填写不对,无法重置密码!")); } } } else { return(Error("当前用户不存在")); } }
public ActionResult Index(FormCollection fc) { if (!string.IsNullOrEmpty(Request["name"]) && !string.IsNullOrEmpty(Request["pwd"])) { var name = Request["name"]; var pwd = Request["pwd"]; var user = _userBll.Query(name); if (user == null) { SetTempData("用户不存在,请核对账号是否正确!"); return(RedirectToAction("Index")); } if (user.IsLock) { SetTempData("用户已锁定,请联系管理员进行解锁!"); return(RedirectToAction("Index")); } if (DesEncrypt.Encrypt(pwd, user.Salt) != user.Password) { SetTempData("密码错误,请重新输入!"); return(RedirectToAction("Index")); } var roleIdList = user?.Roles.Select(x => x.RoleId).Distinct(); //登陆重定向 Session.Add("User", user); Session.Add("RoleIdList", roleIdList); var userIdentity = new UserIdentity(user.LoginName, true, 7200); foreach (var role in user.Roles) { userIdentity.Roles.Add(role.Code); } //认证 var token = AuthManager.Login(userIdentity); CacheHelper.Insert(user.LoginName, token, 7200); return(RedirectToAction("Index", "Manager")); } else { SetTempData("用户名或者密码不能为空!"); return(RedirectToAction("Index")); } }
/// <summary> /// 修改密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnConfirm_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } _systemUserModel = _systemUserBll.GetModel(Convert.ToInt32(Session["userid"])); string password = DesEncrypt.GetMd5String(txtPassword.Text); string pwd = DesEncrypt.GetMd5String(txtPwd.Text); if (_systemUserModel != null) { if (_systemUserModel.UserPwd.ToUpper() == password.ToUpper()) { if (txtPwd.Text != txtRpwd.Text) { Alert("新密码和确认密码不一样!"); } else { if (_systemUserModel.UserPwd == pwd || pwd.Length < 6) { Alert("新密码和旧密码太相似,且密码长度不少于6位,请重新设置!"); } else { _systemUserModel.UserPwd = pwd; if (_systemUserBll.Update(_systemUserModel)) { Session.Abandon(); AlertAndParentReoload("修改成功!"); AddSystemLog("用户修改密码", "修改"); } } } } else { Alert("原密码不正确!"); } } else { Alert("没找到该用户!"); } }
/// <summary> /// 更新密码 /// </summary> /// <param name="entityAccountPwd"></param> public async Task UpdateAccountPwd(EntityAccountPwd entityAccountPwd) { var userSalt = Utils.GetCheckCode(16); var model = new TableAccountManager() { Id = entityAccountPwd.Id, UserPwd = DesEncrypt.Encrypt(entityAccountPwd.UserPwd.Trim().Trim(), userSalt), UserSalt = userSalt }; var accountRep = GetRepositoryInstance <TableAccountManager>(); accountRep.Update <TableAccountManager>(model, managerInfo => new { managerInfo.UserPwd, managerInfo.UserSalt }); }
static void Main(string[] args) { try { #region MD5 //1 防止看到明文 数据库密码,加盐(原密码+固定字符串,然后再MD5/双MD5) //2 防篡改 //急速秒传(第一次上传文件,保存md5摘要,第二次上传检查md5摘要) //文件下载(防篡改,官方发布的时候给一个md5摘要,安装的时候首先检查下摘要) //svn TFS git VSS(本地保存文件的md5摘要,任何修改都会影响md5) //3 防止抵赖 Console.WriteLine(MD5Encrypt.Encrypt("1")); Console.WriteLine(MD5Encrypt.Encrypt("1")); Console.WriteLine(MD5Encrypt.Encrypt("123456小李")); Console.WriteLine(MD5Encrypt.Encrypt("113456小李")); Console.WriteLine(MD5Encrypt.Encrypt("113456小李113456小李113456小李113456小李113456小李113456小李113456小李")); string md5Abstract1 = MD5Encrypt.AbstractFile(@"D:\ruanmou\online9\homework\1\Advanced9第一次作业优秀合集.rar"); string md5Abstract2 = MD5Encrypt.AbstractFile(@"D:\ruanmou\online9\homework\1\Advanced9第一次作业优秀合集 - 副本.rar"); #endregion #region Des //可逆对称加密 string desEn = DesEncrypt.Encrypt("王殃殃"); string desDe = DesEncrypt.Decrypt(desEn); string desEn1 = DesEncrypt.Encrypt("张三李四"); string desDe1 = DesEncrypt.Decrypt(desEn1); #endregion #region Rsa //可逆非对称加密 KeyValuePair <string, string> encryptDecrypt = RsaEncrypt.GetKeyPair(); string rsaEn1 = RsaEncrypt.Encrypt("net", encryptDecrypt.Key); //key是加密的 string rsaDe1 = RsaEncrypt.Decrypt(rsaEn1, encryptDecrypt.Value); //value 解密的 不能反过来用的 //加密钥 解密钥 钥匙的功能划分 //公钥 私钥 公开程度划分 #endregion } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }