public IDictionary <string, object> SaveGroup(IDictionary <string, object> parameters) { using (_dal) { long groupId = long.Parse(parameters["GroupId"].ToString()); string isModify = parameters["IsModify"].ToString(); if (isModify == "1") { string aesKey = parameters["AesKey"].ToString(); string aesIv = parameters["AesIv"].ToString(); string securityKey = parameters["SecurityKey"].ToString(); aesKey = RsaCryptoUtils.Decrypt(AesCryptoUtils.base64UrlDecode(aesKey), RsaCryptoUtils.GetPublicKey(), RsaCryptoUtils.GetPrivateKey(), 1024); aesIv = RsaCryptoUtils.Decrypt(AesCryptoUtils.base64UrlDecode(aesIv), RsaCryptoUtils.GetPublicKey(), RsaCryptoUtils.GetPrivateKey(), 1024); byte[] aesKeyByte = Encoding.UTF8.GetBytes(aesKey); byte[] aesIvByte = Encoding.UTF8.GetBytes(aesIv); securityKey = AesCryptoUtils.Decrypt(securityKey, aesKeyByte, aesIvByte); aesKeyByte = Encoding.UTF8.GetBytes(AppConfigurtaionHelper.Configuration.GetValue <string>("AesCrypto:Key")); aesIvByte = Encoding.UTF8.GetBytes(AppConfigurtaionHelper.Configuration.GetValue <string>("AesCrypto:Iv")); securityKey = AesCryptoUtils.Encrypt(securityKey, aesKeyByte, aesIvByte); parameters["SecurityKey"] = securityKey; } parameters.Remove("IsModify"); parameters.Remove("AesIv"); parameters.Remove("AesKey"); if (groupId == 0) { return(_dal.InsertGroup(parameters)); } else { return(_dal.UpdateGroup(parameters)); } } }
public object Login([FromBody] dynamic model) { IDictionary <string, object> parameters = RequestDataHelper.GetMixParams(); string username = parameters["username"].ToString(); string password = parameters["password"].ToString(); if (_configuration.GetValue <string>("AdminAccount:Account") == username && _configuration.GetValue <string>("AdminAccount:Password") == password) { HttpContext.Session.SetString("User", JsonConvert.SerializeObject(parameters)); //跳转到系统首页 return(RsaCryptoUtils.GetPublicKey()); } else { throw new CustomException(11, "用户名或密码错误"); } }