/// <summary> /// 获取用户订单信息 /// </summary> /// <param name="symbol">btc_usd:比特币 ltc_usd :莱特币</param> /// <param name="contractType">合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度</param> /// <param name="orderId">订单ID(-1查询全部未成交订单,否则查询相应单号的订单)</param> /// <param name="status">查询状态:1:未完成(最近七天的数据) 2:已完成(最近七天的数据)</param> /// <param name="currentPage">当前页数</param> /// <param name="pageLength">每页获取条数,最多不超过50</param> /// <returns></returns> public String future_order_info(String symbol, String contractType, String orderId, String status, String currentPage, String pageLength) { String result = ""; try { // 构造参数签名 Dictionary <String, String> paras = new Dictionary <String, String>(); if (!StringUtil.isEmpty(contractType)) { paras.Add("contract_type", contractType); } if (!StringUtil.isEmpty(currentPage)) { paras.Add("current_page", currentPage); } if (!StringUtil.isEmpty(orderId)) { paras.Add("order_id", orderId); } if (!StringUtil.isEmpty(api_key)) { paras.Add("api_key", api_key); } if (!StringUtil.isEmpty(pageLength)) { paras.Add("page_length", pageLength); } if (!StringUtil.isEmpty(symbol)) { paras.Add("symbol", symbol); } if (!StringUtil.isEmpty(status)) { paras.Add("status", status); } String sign = MD5Util.buildMysignV1(paras, secret_key); paras.Add("sign", sign); // 发送post请求 HttpUtilManager httpUtil = HttpUtilManager.getInstance(); result = httpUtil.requestHttpPost(url_prex, FUTURE_ORDER_INFO_URL, paras); } catch (Exception e) { throw e; } return(result); }
public LogSubscriber() { param = new MQTTClientParam(); param.clientID = Guid.NewGuid().ToString(); param.ip = Config.envConfigInfo.confLogServiceInfo.IP; param.port = Config.envConfigInfo.confLogServiceInfo.Port; param.userName = Config.envConfigInfo.confLogServiceInfo.UserName; param.password = MD5Util.MD5Decrypt(Config.envConfigInfo.confLogServiceInfo.Password); filePath = Config.envConfigInfo.confLogServiceInfo.filePath; tableName = Config.envConfigInfo.confLogServiceInfo.tableName; newsTopic = Config.envConfigInfo.confLogServiceInfo.NewsTopic; }
/// <summary> /// 期货下单 /// </summary> /// <param name="symbol">btc_usd:比特币 ltc_usd :莱特币</param> /// <param name="contractType">合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度</param> /// <param name="price">价格</param> /// <param name="amount">委托数量</param> /// <param name="type">1:开多 2:开空 3:平多 4:平空</param> /// <param name="matchPrice">是否为对手价 0:不是 1:是 ,当取值为1时,price无效</param> /// <param name="leverRate">杠杆率,10或20</param> /// <returns></returns> public void future_async_trade_ex(String symbol, String contractType, String price, String amount, String type, String matchPrice, String leverRate, HttpAsyncReq.ResponseCallback callback) { try { // 构造参数签名 Dictionary <String, String> paras = new Dictionary <String, String>(); if (!StringUtil.isEmpty(symbol)) { paras.Add("symbol", symbol); } if (!StringUtil.isEmpty(contractType)) { paras.Add("contract_type", contractType); } if (!StringUtil.isEmpty(api_key)) { paras.Add("api_key", api_key); } if (!StringUtil.isEmpty(price)) { paras.Add("price", price); } if (!StringUtil.isEmpty(amount)) { paras.Add("amount", amount); } if (!StringUtil.isEmpty(type)) { paras.Add("type", type); } if (!StringUtil.isEmpty(matchPrice)) { paras.Add("match_price", matchPrice); } if (!StringUtil.isEmpty(leverRate)) { paras.Add("lever_rate", leverRate); } String sign = MD5Util.buildMysignV1(paras, secret_key); paras.Add("sign", sign); // 发送post请求 HttpUtilManager httpUtil = HttpUtilManager.getInstance(); httpUtil.requestHttpPostAsync(url_prex, FUTURE_TRADE_URL, paras, callback); } catch (Exception e) { throw e; } }
public string GenerateMd5(SerializationGenerator generator) { List <byte> codeMd5 = new List <byte>(); foreach (var node in generator.RegisteredTypes) { if (node.CodeMd5 != null) { codeMd5.AddRange(node.CodeMd5); } } return(MD5Util.Md5ToString(MD5Util.MD5(codeMd5.ToArray()))); }
public static List <AssetBundleData> BuildAssetBundleData(AssetBundleRule[] assetBundleRules) { List <AssetBundleData> assetBundleDataList = new List <AssetBundleData>(); List <string> assetNameList = new List <string>(); foreach (AssetBundleRule item in assetBundleRules) { if (item.assetBundleRuleType == AssetBundleRuleType.File) { FileInfo[] fileInfos = FileUtil.GetFiles(new DirectoryInfo(item.path), new List <FileInfo>()); if (fileInfos.Length == 0) { continue; } List <FileInfo> fileInfoList = (from fileInfo in fileInfos where !string.IsNullOrEmpty(Path.GetExtension(fileInfo.Name)) && Path.GetExtension(fileInfo.Name) != ".meta" select fileInfo).ToList(); foreach (FileInfo fileInfo in fileInfoList) { string assetName = fileInfo.FullName.Substring(fileInfo.FullName.IndexOf("Assets")).Replace("\\", "/"); string md5 = MD5Util.ComputeMD5(assetName); assetBundleDataList.Add(new AssetBundleData($"{md5}.unity3d", string.Empty, uint.MinValue, long.MinValue, new string[] { assetName })); } } if (item.assetBundleRuleType == AssetBundleRuleType.Directory) { DirectoryInfo[] directoryInfos = DirectoryUtil.GetDirectorys(new DirectoryInfo(item.path), new List <DirectoryInfo>()); if (directoryInfos.Length == 0) { continue; } foreach (DirectoryInfo directoryInfo in directoryInfos) { FileInfo[] fileInfos = directoryInfo.GetFiles(); if (fileInfos.Length == 0) { continue; } List <FileInfo> fileInfoList = (from fileInfo in fileInfos where !string.IsNullOrEmpty(Path.GetExtension(fileInfo.Name)) && Path.GetExtension(fileInfo.Name) != ".meta" select fileInfo).ToList(); foreach (FileInfo fileInfo in fileInfoList) { assetNameList.Add(fileInfo.FullName.Substring(fileInfo.FullName.IndexOf("Assets")).Replace("\\", "/")); } string assetName = directoryInfo.FullName.Substring(directoryInfo.FullName.IndexOf("Assets")).Replace("\\", "/"); string md5 = MD5Util.ComputeMD5(assetName); assetBundleDataList.Add(new AssetBundleData($"{md5}.unity3d", string.Empty, uint.MinValue, long.MinValue, assetNameList.ToArray())); assetNameList.Clear(); } } } return(assetBundleDataList); }
public async Task <ResponseViewModel <object> > Forget(ForgetViewModel vm) { var data = new ResponseViewModel <object>(); var user = await _userProvider.GetUserInfo(vm.EMP_EMAIL); if (user != null) { //发送找回密码邮件 var tempHtml = "<p>{0}</p>"; var body = string.Empty; var url = _config.Domain + "/account/reset?token=" + MD5Util.TextToMD5(user.EMP_EMAIL); var link = "<a href='" + url + "'>" + url + "</a>"; body += string.Format(tempHtml, _localizer["forget.body1"]); body += string.Format(tempHtml, user.LoginName + _localizer["forget.body2"]); body += string.Format(tempHtml, _localizer["forget.body3"] + link); body += string.Format(tempHtml, _localizer["forget.body4"]); body += string.Format(tempHtml, _localizer["forget.body5"]); data.Msg = _localizer["forget.success"]; var verify = new VerifyEntity { UserId = user.ID, Token = MD5Util.TextToMD5(user.EMP_EMAIL), Status = (int)VerifyStatusEnum.Normal, Type = (int)VerifyTypeEnum.Password, Time = DateTime.Now }; await _verifyProvider.AddVerify(verify); try { _email.SendEmail(user.LoginName, user.EMP_EMAIL, _localizer["forget.subject"], body); } catch (Exception e) { data.Code = 1; data.Msg = e.Message; } } else { data.Code = 1; data.Msg = _localizer["forget.inexistent"]; } return(data); }
/// <summary> /// 租户登陆验证。 /// </summary> /// <param name="userName">用户名</param> /// <param name="password">密码(第一次md5加密后)</param> /// <returns>验证成功返回用户实体,验证失败返回null|提示消息</returns> public async Task <Tuple <Tenant, string> > Validate(string userName, string password) { var userEntity = await _repository.GetByUserName(userName); if (userEntity == null) { return(new Tuple <Tenant, string>(null, "系统不存在该用户,请重新确认。")); } if (!userEntity.EnabledMark) { return(new Tuple <Tenant, string>(null, "该用户已被禁用,请联系管理员。")); } var userSinginEntity = _repositoryLogon.GetByTenantId(userEntity.Id); string inputPassword = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(password).ToLower(), userSinginEntity.TenantSecretkey).ToLower()).ToLower(); if (inputPassword != userSinginEntity.TenantPassword) { return(new Tuple <Tenant, string>(null, "密码错误,请重新输入。")); } else { TenantLogon userLogOn = _repositoryLogon.GetWhere("UserId='" + userEntity.Id + "'"); if (userLogOn.AllowEndTime < DateTime.Now) { return(new Tuple <Tenant, string>(null, "您的账号已过期,请联系系统管理员!")); } if (userLogOn.LockEndDate > DateTime.Now) { string dateStr = userLogOn.LockEndDate.ToEasyStringDQ(); return(new Tuple <Tenant, string>(null, "当前被锁定,请" + dateStr + "登录")); } if (userLogOn.FirstVisitTime == null) { userLogOn.FirstVisitTime = userLogOn.PreviousVisitTime = DateTime.Now; } else { userLogOn.PreviousVisitTime = DateTime.Now; } userLogOn.LogOnCount++; userLogOn.LastVisitTime = DateTime.Now; userLogOn.TenantOnLine = true; await _repositoryLogon.UpdateAsync(userLogOn, userLogOn.Id); return(new Tuple <Tenant, string>(userEntity, "")); } }
/// <summary> /// 期货下单 /// </summary> /// <param name="symbol">btc_usd:比特币 ltc_usd :莱特币</param> /// <param name="contractType">合约类型: this_week:当周 next_week:下周 month:当月 quarter:季度</param> /// <param name="price">价格</param> /// <param name="amount">委托数量</param> /// <param name="type">1:开多 2:开空 3:平多 4:平空</param> /// <param name="matchPrice">是否为对手价 0:不是 1:是 ,当取值为1时,price无效</param> /// <returns></returns> public String future_trade(String symbol, String contractType, String price, String amount, String type, String matchPrice) { String result = ""; try { // 构造参数签名 Dictionary <String, String> paras = new Dictionary <String, String>(); if (!StringUtil.isEmpty(symbol)) { paras.Add("symbol", symbol); } if (!StringUtil.isEmpty(contractType)) { paras.Add("contract_type", contractType); } if (!StringUtil.isEmpty(api_key)) { paras.Add("api_key", api_key); } if (!StringUtil.isEmpty(price)) { paras.Add("price", price); } if (!StringUtil.isEmpty(amount)) { paras.Add("amount", amount); } if (!StringUtil.isEmpty(type)) { paras.Add("type", type); } if (!StringUtil.isEmpty(matchPrice)) { paras.Add("match_price", matchPrice); } String sign = MD5Util.buildMysignV1(paras, secret_key); paras.Add("sign", sign); // 发送post请求 HttpUtilManager httpUtil = HttpUtilManager.getInstance(); result = httpUtil.requestHttpPost(url_prex, FUTURE_TRADE_URL, paras); } catch (Exception e) { Console.WriteLine("重新连接"); future_trade(symbol, contractType, price, amount, type, matchPrice); } return(result); }
public ResponseModel <BCSysAccountDTO> Login(BCLoginDTO bcloginDTO) { var result = new ResponseModel <BCSysAccountDTO>(); var data = new BCSysAccountDTO(); result.error_code = Result.SUCCESS; result.message = ""; var info = _sysAccountService.Login(bcloginDTO.account, bcloginDTO.password);//.SysBusinessAccount(sysBusinessAccountLoginDto.account, sysBusinessAccountLoginDto.password); if (info == null || info.SysAccountId <= 0) { result.error_code = Result.ERROR; result.message = "您输入的帐号或密码错误,请重新输入"; result.data = data; return(result); } else { DateTime time = System.DateTime.Now; if (info.LoginTime.AddMonths(1) < System.DateTime.Now || string.IsNullOrWhiteSpace(info.Token))//过期 { string tokenstr = MD5Util.GetMD5_32(info.PassWord + info.SysAccountId + time.ToString("yyyy:MM:dd HH:mm:ss") + token_key); data.last_loin_time = info.LoginTime.ToString("yyyy:MM:dd HH:mm:ss"); data.nick_name = info.NickName; data.path = info.BaseImage == null ? "" : info.BaseImage.Source + info.BaseImage.Path; data.phone_no = info.MobilePhone; data.sys_business_account_id = info.BusinessInfoId; data.token_str = tokenstr; data.account = info.Account; info.Token = tokenstr; info.LoginTime = time; _sysAccountService.Update(info); result.data = data; } else { data.last_loin_time = info.LoginTime.ToString("yyyy:MM:dd HH:mm:ss"); data.nick_name = info.NickName; data.path = info.BaseImage == null ? "" : info.BaseImage.Source + info.BaseImage.Path; data.phone_no = info.MobilePhone; data.sys_business_account_id = info.BusinessInfoId; data.token_str = info.Token; data.account = info.Account; info.LoginTime = System.DateTime.Now; _sysAccountService.Update(info); result.data = data; } } return(result); }
/// <summary> /// 新增前处理数据 /// </summary> /// <param name="info"></param> protected override void OnBeforeInsert(APP info) { info.Id = GuidUtils.CreateNo(); info.AppSecret = MD5Util.GetMD5_32(GuidUtils.NewGuidFormatN()).ToUpper(); if (info.IsOpenAEKey) { info.EncodingAESKey = MD5Util.GetMD5_32(GuidUtils.NewGuidFormatN()).ToUpper(); } info.CreatorTime = DateTime.Now; info.CreatorUserId = CurrentUser.UserId; info.CompanyId = CurrentUser.OrganizeId; info.DeptId = CurrentUser.DeptId; info.DeleteMark = false; }
/// <summary> /// 会员 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSave(object sender, MouseEventArgs e) { string error = string.Empty; if (!this.IsValid(ref error)) { MessageBox.Show(error, "注册会员"); return; } Member member = new Member(); member.ShopId = this.txtShopId.Text.Trim(); member.Password = MD5Util.GetMd5String(this.txtPassword.Text.Trim()); member.CreateDate = this.txtCreateDate.Text.Trim(); member.Level = this.txtLevel.Text.Trim(); member.Status = this.txtStatus.Text.Trim(); member.Number = this.txtNumber.Text.Trim(); if (rbSexTypeMan.Checked) { member.SexType = SexType.Man; } else { member.SexType = SexType.Women; } member.Name = this.txtName.Text.Trim(); member.Email = this.txtEmail.Text.Trim(); member.BirthDate = new DateTime(int.Parse(this.txtBirthDateYear.Text), int.Parse(this.txtBirthDateMonth.Text), int.Parse(this.txtBirthDateDay.Text)); member.Occupation = this.txtOccupation.Text.Trim(); member.Phone = this.txtPhone.Text.Trim(); member.QQ = this.txtQQ.Text.Trim(); member.Adviser = this.txtAdviser.Text.Trim(); member.Province = this.txtProvince.Text.Trim(); member.City = this.txtCity.Text.Trim(); member.County = this.txtCounty.Text.Trim(); member.Address = this.txtAddress.Text.Trim(); member.Code = this.txtCode.Text.Trim(); using (SkinDbContext context = new SkinDbContext()) { context.Members.Add(member); context.SaveChanges(); } // 进入 }
public string CompressNestedFolder(IEnumerable <dynamic> documents, IEnumerable <Tuple <string, string> > zipEntryItems) { var temp = Path.Combine(rootPath2, "ZipTemp"); if (!Directory.Exists(temp)) { Directory.CreateDirectory(temp); } var md5s = string.Join(",", zipEntryItems.Select(o => o.Item1)); var md5 = MD5Util.GetMd5(md5s); var zipName = string.Format("{0}\\{1}{2}", temp, md5, ".zip"); if (File.Exists(zipName)) { return(md5); } using (ZipOutputStream zipOutputStream = new ZipOutputStream(File.Create(zipName))) { zipOutputStream.SetLevel(9); var abyBuffer = new byte[4096]; foreach (var zipEntryItem in zipEntryItems) { var document = documents.FirstOrDefault(o => o.md5 == zipEntryItem.Item1); if (document == null) { continue; } string filename = document.file; string name = document.name; string extension = document.extension; using (FileStream filestream = File.OpenRead(filename)) { var zipEntry = new ZipEntry(zipEntryItem.Item2); zipEntry.DateTime = DateTime.Now; zipEntry.Size = filestream.Length; zipOutputStream.PutNextEntry(zipEntry); StreamUtils.Copy(filestream, zipOutputStream, abyBuffer); } } } return(md5); }
private static void OnCompleteLoveDiary(DownloadItem downloadItem) { if (downloadItem.Md5 != MD5Util.Get(downloadItem.LocalPath)) { FlowText.ShowMessage(I18NManager.Get("Download_ErrorAndRetry")); File.Delete(downloadItem.LocalPath); return; } bool isEnd = false; progress = 0; Tweener tween = DOTween.To(() => progress, val => progress = val, 100, 1.5f); tween.onComplete = () => { if (isEnd == false) { isEnd = true; } else { _onComplete?.Invoke(_tag); } }; Loom.RunAsync(() => { if (downloadItem.FileType == FileType.Zip) { ZipUtil.Unzip(downloadItem.LocalPath, AssetLoader.ExternalHotfixPath + "/" + _releasePath); } Loom.QueueOnMainThread(() => { if (isEnd == false) { isEnd = true; } else { _onComplete?.Invoke(_tag); } }); }); }
public static bool Valid(long appId, string appSecret) { using (var db = new HGDContext()) { // AppInfo e = (from ai in db.AppInfo where ai.Id == appId select ai) .FirstOrDefault(); string hashAppSecret = MD5Util.getHashStr(appSecret); return(e != null && e.Secret.ToLower() == hashAppSecret); } }
private string FromatApiRecordKey(string api, Policy policy, string policyKey, string policyValue) { var key = $"apithrottle:cache:record:{policy.ToString().ToLower()}"; if (!string.IsNullOrEmpty(policyKey)) { key += ":" + MD5Util.EncryptMD5Short(policyKey); } if (!string.IsNullOrEmpty(policyValue)) { key += ":" + MD5Util.EncryptMD5Short(policyValue); } key += ":" + api.ToLower(); return(key); }
public void generateUser() { var list = database.County.Where(t => t.Level == (int)Level.City || t.Level == (int)Level.County).ToList(); foreach (var item in list) { User user = new User(); user.LoginCode = item.Id; user.Password = MD5Util.EncryptWithMD5(InitialPassword); user.Role = Role.Admin; user.CountyId = item.Id; database.User.Add(user); } database.SaveChanges(); }
public void CheckSign() { if (string.IsNullOrEmpty(AppId)) { throw new Exception("缺少appid"); } if (string.IsNullOrEmpty(Sign)) { throw new Exception("缺少sign"); } if (string.IsNullOrEmpty(Timestamp)) { throw new Exception("缺少timestamp"); } long timestamp = 0; if (!long.TryParse(Timestamp, out timestamp)) { throw new Exception("timestamp必须是整形"); } var time = ConvertTimeStampToDateTime(timestamp); if (time > DateTime.Now.AddMinutes(5) || time < DateTime.Now.AddMinutes(-5)) { throw new Exception("时间戳错误"); } var values = GetValues(); values.Add("sign", Sign); values.Add("appid", AppId); values.Add("timestamp", Timestamp); var result = MD5AuthorizeConfigs.Instance.GetSingle(AppId); if (result == null) { //loginfo.DebugFormat("MD5:不存在AppId为{0}的相关信息", sortDic["appid"]); throw new Exception("MD5:不存在AppId为" + AppId + "的相关信息"); } var key = result.ClientSecret; bool isSign = MD5Util.Verify(values, Sign, key); if (!isSign) { throw new Exception("MD5签名错误"); } }
public void Export(SerializationGenerator generator, string nameSpace, string targetFolder) { foreach (var pair in generator.RegisteredTypes) { if (pair.IsEnum) { continue; } var builder = new TextBuilder(); VisitRoot(pair, nameSpace, builder); pair.CodeMd5 = MD5Util.MD5(builder.ToString()); builder.WriteToFile(Path.Combine(targetFolder, pair.FileName + ".cs")); } }
//兑奖 public void NcExchargeRequest(HallTransfer.ExchangeRequest tempRecharge) { uint UserID = GameApp.GameData.UserInfo.UserID; Int64 Money = tempRecharge.dwMoney; string dwNote = tempRecharge.dwRemark; string passWord = MD5Util.GetMD5Hash(tempRecharge.dwPassword); string Key = GameApp.GameData.PrivateKey; GameApp.BackendSrv.Exchange(UserID, Money, dwNote, passWord, Key, b => { if (b != null) { HallTransfer.Instance.cnAwardResult(b.Code, b.Msg); } }); }
public static String Sign(String content, String key) { String signStr = ""; if ("" == key) { throw new SDKRuntimeException("财付通签名key不能为空!"); } if ("" == content) { throw new SDKRuntimeException("财付通签名内容不能为空"); } signStr = content + "&key=" + key; return(MD5Util.MD5(signStr).ToUpper()); }
// -1--未知错误 // 0--密码错误 // 1--操作成功 public int Login(User user) { try { string encryptPass = MD5Util.GetMD5(user.UserPass); var res = (from s in db.User where s.UserName == user.UserName && s.UserPass == encryptPass select s.UserId).Count(); return(res); } catch (Exception e) { // return(-1); } }
// [MenuItem("AssetBundle/===发布===/TEST")] public static void AllBundleConfig() { Stopwatch sw = Stopwatch.StartNew(); Dictionary <string, BundleStruct> dict = new Dictionary <string, BundleStruct>(); DirectoryInfo dir = new DirectoryInfo(GetAssetBundleDir()); string rootPath = GetAssetBundleDir().Replace("\\", "/"); int len = rootPath.Length; FileInfo[] files = dir.GetFiles("*.*", SearchOption.AllDirectories); foreach (var fileInfo in files) { if (fileInfo.Extension == ".manifest") { continue; } string key = fileInfo.FullName.Replace("\\", "/"); key = key.Substring(len + 1); BundleStruct val = new BundleStruct(); val.Md5 = MD5Util.Get(fileInfo.FullName); val.Size = fileInfo.Length; dict.Add(key, val); } byte[] contentBuffer; using (MemoryStream stream = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, dict); contentBuffer = stream.GetBuffer(); } using (FileStream fileStream = new FileStream(OutputPath + "/bundle.config", FileMode.Create, FileAccess.Write, FileShare.None)) { BinaryWriter br = new BinaryWriter(fileStream); br.Write(contentBuffer); br.Close(); } Debug.Log("<color='#00ff66'>AllBundleConfig:" + sw.ElapsedMilliseconds / 1000.0f + "s</color>"); }
public ActionResult ChangePassword(string oldPwd, string newPwdConfim) { if (MD5Util.Encrypt(oldPwd) != CurrentUser.loginPwd) { ViewBag.Error = "旧密码不正确"; return(View()); } if (Smart.Instance.UserBizService.ChangePassword(CurrentUser.Id, MD5Util.Encrypt(newPwdConfim))) { ViewBag.Error = "1"; } else { ViewBag.Error = "修改失败"; } return(View()); }
/// <summary> /// 获取【饿了么】签名字符串 /// </summary> /// <param name="dic">待签名参数</param> /// <param name="secret">应用密钥</param> /// <param name="action">接口方法</param> /// <param name="token">访问令牌</param> /// <param name="secret">应用密钥</param> /// <returns></returns> public static string GetEleSign(SortedDictionary <string, object> dic, string secret, bool isToJson = false, string action = "", string token = "") { var strSign = string.Empty; var strRequestData = string.Empty; StringBuilder sbRequest = new StringBuilder(); foreach (var item in dic) { sbRequest.AppendFormat("{0}={1}", item.Key, isToJson ? item.Value.ToJson() : item.Value); } //拼接加密字符串串 strRequestData = string.Format("{0}{1}{2}{3}", action, token, sbRequest.ToString(), secret); strSign = MD5Util.Sign(strRequestData, "").ToUpper(); return(strSign); }
private bool CheckMd5() { //如果md5为空,不检查md5 if (Md5 == null) { return(true); } string targetMd5 = MD5Util.Get(LocalPath); if (targetMd5 != Md5) { return(false); } return(true); }
public bool resetPassword(int userId) { if (userId == 0) { return(false); } User user = database.User.Find(userId); if (user == null) { return(false); } user.Password = MD5Util.EncryptWithMD5(InitialPassword); database.Entry(user).State = System.Data.Entity.EntityState.Modified; database.SaveChanges(); return(true); }
/// <summary> /// 校验登录用户 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns>0:验证失败 1:普通用户 2:管理员</returns> public SessionUser CheckUser(string username, string password) { User user = _userMapper.FindUserByUsername(username); password = MD5Util.MD5Encrypt(password); if (user == null || !password.Equals(user.Password)) { return(null); } SessionUser suser = new SessionUser(); suser.Id = user.Id; suser.Username = user.Username; suser.Name = user.Name; suser.Type = user.Type; return(suser); }
public static long Add(string appSecret, string name) { using (var db = new HGDContext()) { // AppInfo e = new AppInfo(); e.Id = LeafSnowflake.getID(); e.Secret = MD5Util.getHashStr(appSecret); e.Name = name; db.AppInfo.Add(e); db.SaveChanges(); return(e.Id); } }
/// <summary> /// 验证客户端 /// </summary> /// <param name="context"></param> private void ClientCheck(MqttConnectionValidatorContext context) { //string clientIdStartsWith = ""; // int clientIdMinLegth = 0; //if (context.ClientId.Length < clientIdMinLegth || !context.ClientId.StartsWith(clientIdStartsWith)) //{ // context.ReturnCode = MqttConnectReturnCode.ConnectionRefusedIdentifierRejected; // return; //} if (context.Username != this.mqttParam.userName || MD5Util.MD5Encrypt(context.Password) != this.mqttParam.password) { context.ReturnCode = MqttConnectReturnCode.ConnectionRefusedBadUsernameOrPassword; return; } context.ReturnCode = MqttConnectReturnCode.ConnectionAccepted; }
// public AccountService(IMapper mapper) // { // _mapper = mapper; // } public ServerResponse <UserDto> login(String username, String password) { int resultCount = _userservice.checkUsername(username); if (resultCount == 0) { return(ServerResponse <UserDto> .createByErrorMessage("用户名不存在")); } String md5Password = MD5Util.GetMD5(password); User user = _userservice.selectLogin(username, md5Password); var userdto = _mapper.Map <UserDto>(user); if (user == null) { return(ServerResponse <UserDto> .createByErrorMessage("密码错误")); } return(ServerResponse <UserDto> .createBySuccess("登录成功", userdto)); }