public bool UpdateFlagSupport(Admin admin, int id, bool state) { if (admin == null || string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password)) { return(false); } string password = MD5Hashing.Hash(admin.Password); if (Db.Admins.SingleOrDefault(x => x.Username == admin.Username && x.Password == password) != null) { Support support = Db.Supports.SingleOrDefault(x => x.Id == id); if (support != null) { support.IsFlagged = state; Db.SaveChanges(); return(true); } else { return(false); } } else { return(false); } }
public bool ReplySupport(Admin admin, Consumer consumer, string text) { if (admin == null || string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password)) { return(false); } string password = MD5Hashing.Hash(admin.Password); if (Db.Admins.SingleOrDefault(x => x.Username == admin.Username && x.Password == password) != null) { try { // Send reply to consumer return(true); } catch (Exception) { return(false); } } else { return(false); } }
private static void GenerateAndroidDllConfig(string pathToBuildProject) { var backupFolder = GetAndroidBackupDllFolder(pathToBuildProject); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = DateTime.UtcNow.ToFileTimeUtc(); FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, GetDecodeApkFolder(pathToBuildProject) + "/assets/dllVersion.json"); }
public bool DeleteSupport(Admin admin, int id) { if (admin == null || string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password)) { return(false); } string password = MD5Hashing.Hash(admin.Password); if (Db.Admins.SingleOrDefault(x => x.Username == admin.Username && x.Password == password) != null) { Support message = Db.Supports.SingleOrDefault(x => x.Id == id); if (message == null) { return(false); } else { Db.Supports.Remove(message); Db.SaveChanges(); return(true); } } else { return(false); } }
public Support ViewSupport(Admin admin, int id) { if (admin == null || string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password)) { return(null); } string password = MD5Hashing.Hash(admin.Password); if (Db.Admins.SingleOrDefault(x => x.Username == admin.Username && x.Password == password) != null) { Support support = Db.Supports.SingleOrDefault(x => x.Id == id); if (support != null) { support.IsRead = true; Db.SaveChanges(); return(support); } else { return(null); } } else { return(null); } }
public ListModel ListSupports(Admin admin) { if (admin == null || string.IsNullOrEmpty(admin.Username) || string.IsNullOrEmpty(admin.Password)) { return(null); } string password = MD5Hashing.Hash(admin.Password); if (Db.Admins.SingleOrDefault(x => x.Username == admin.Username && x.Password == password) != null) { Support[] arry = new Support[1]; arry[0] = new Support() { Content = "deneme" }; return(new ListModel() { List = arry }); } else { return(null); } }
private static void GenerateAndroidDllConfig(string pathToBuildProject) { var backupFolder = GetAndroidBackupDllFolder(pathToBuildProject); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = AssetManager.GetVisualDateTimeNow(); if (dllVersion.Version > DllHelper.Max_Versoin) { throw new Exception("dll版本号居然比限定的最大版本号还要大!"); } FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, GetDecodeApkFolder(pathToBuildProject) + "/assets/dllVersion.json"); ChangeAndroidManifestDllVersion(pathToBuildProject, dllVersion.Version); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var user = new UserProfile(); user.ActiveInd = true; user.UserName = username; user.Email = email; user.Password = MD5Hashing.MD5Hash(password); user.FirstName = " "; user.LastName = " "; user.LockedInInd = false; user.LanguageCode = "en"; user.DefaultTheme = "vista"; user.DatePreference = "en"; user.PreferedWeightMeasurment = "MT"; try { //TODO:More refactoring required repository.UserProfileRepository.Add(user); status = MembershipCreateStatus.Success; return(GetMembershipUser(user)); } catch (Exception e) { status = MembershipCreateStatus.ProviderError; } return(null); }
private static void GenerateWinDllConfig(string rootFolder, string dataPath) { var backupFolder = GetWinBackupDllFolder(rootFolder); var dllVersion = new DllVersion(); foreach (var file in Directory.GetFiles(backupFolder, "*.dll")) { var name = Path.GetFileNameWithoutExtension(file); var md5 = MD5Hashing.HashFile(file); var size = (new FileInfo(file)).Length; var dllInfo = new DllInfo() { dllName = name, MD5 = md5, size = size, }; dllVersion.Manifest.Add(name, dllInfo); FileUtil.MoveFileOrDirectory(file, backupFolder + "/" + dllInfo.ToFileName()); } dllVersion.Version = AssetManager.GetVisualDateTimeNow(); FileHelper.SaveJsonObj(dllVersion, backupFolder + "/" + dllVersion.ToFileName()); FileHelper.SaveJsonObj(dllVersion, dataPath + "/StreamingAssets/" + GameResPath.DLLVERSION_FILE); }
public UIComponentInfo(Transform prefabRoot, string memberName, string path, string type) { this.comType = type; this.memberName = memberName; this.path = path; uid = MD5Hashing.HashString(string.Format("{0}:{1}|{2}", prefabRoot.name, this.memberName, this.path)); }
public UIComponentInfo(GameObject go, Transform prefabRoot) { this.comType = "GameObject"; this.memberName = go.name; this.path = GameObjectExt.GetHierarchyWithRoot(go.transform, prefabRoot); uid = MD5Hashing.HashString(string.Format("{0}:{1}|{2}", prefabRoot.name, this.memberName, this.path)); }
public UIComponentInfo(Component component, Transform prefabRoot) { // this.com = component; this.comType = component.GetType().Name; this.memberName = string.Format("{0}_{1}", component.name, comType); this.path = GameObjectExt.GetHierarchyWithRoot(component.transform, prefabRoot); uid = MD5Hashing.HashString(string.Format("{0}:{1}|{2}", prefabRoot.name, this.memberName, this.path)); }
// TODO: Remove the context here. public override bool ValidateUser(string username, string password) { var userProfileService = (IUserProfileService)DependencyResolver.Current.GetService(typeof(IUserProfileService)); string pass = MD5Hashing.MD5Hash(password); UserProfile user = userProfileService.FindBy(u => u.UserName == username && u.Password == pass && !u.LockedInInd && u.ActiveInd).SingleOrDefault(); return((user != null) ? true : false); }
// TODO: Remove the context here. public override bool ValidateUser(string username, string password) { var entities = new CTSContext(); string pass = MD5Hashing.MD5Hash(password); UserProfile user = (from u in entities.UserProfiles where u.UserName == username && u.Password == pass && !u.LockedInInd && u.ActiveInd select u).SingleOrDefault(); return((user != null) ? true : false); }
public virtual ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { userprofile.Password = MD5Hashing.MD5Hash(userprofile.Password); _userProfileService.AddUserProfile(userprofile); return(Json(new { success = true })); } ViewBag.UserProfileID = new SelectList(_userRoleService.GetAllUserRole(), "UserRoleID", "UserRoleID", userprofile.UserProfileID); return(PartialView("Users/Create", userprofile)); }
public ActionResult ForgetPassword(ForgotPasswordModel model) { if (ModelState.IsValid) { if (_userProfileService.ChangePassword(model.UserProfilID, MD5Hashing.MD5Hash(model.Password))) { _forgetPasswordRequestService.InvalidateRequest(model.UserProfilID); } return(RedirectToAction("LogOn")); } return(View("ForgetPassword", model)); }
private void button1_Click(object sender, EventArgs e) { //Console.WriteLine(login.Text); //onsole.WriteLine(password.Text); if (login.Text != "" && password.Text != "") { erreur.Text = "Connexion..."; Connexion connexion = new Connexion(login.Text, MD5Hashing.MD5Hash(password.Text)); string result = connexion.Connect(); //Console.WriteLine(result); switch (result) { case "erreur_connexion": erreur.Text = "Impossible de se connecter au serveur"; break; case "erreur_log_or_pass1": erreur.Text = "Veuillez entrer correctement vos infos"; break; case "erreur_log_or_pass2": erreur.Text = "Le login ou le mot de passe est erroné"; break; default: try { erreur.Text = "Connecté..."; Process P = Process.Start("jeu_xna.exe", result); Application.Exit(); } catch { erreur.Text = "Une erreur s'est produite"; } break; } } else { //Console.WriteLine(0); //erreur.Text = "0"; Process P = Process.Start("jeu_xna.exe", "0"); Application.Exit(); } }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { if (ValidateUser(username, oldPassword)) { var context = new CTSContext(); UserProfile user = context.UserProfiles.Where(p => p.UserName == username).SingleOrDefault(); if (user != null) { user.Password = MD5Hashing.MD5Hash(newPassword); context.SaveChanges(); return(true); } } return(false); }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { if (ValidateUser(username, oldPassword)) { var userProfileService = (IUserProfileService)DependencyResolver.Current.GetService(typeof(IUserProfileService)); UserProfile user = userProfileService.FindBy(p => p.UserName == username).SingleOrDefault(); if (user != null) { user.Password = MD5Hashing.MD5Hash(newPassword); userProfileService.EditUserProfile(user); return(true); } } return(false); }
public static string GetRawConfigHash() { var files = Directory.GetFiles(RawDataDir, "*.xlsx"); string content = ""; foreach (var file in files) { if (file.Contains("~$")) { continue; } var modifyDate = File.GetLastWriteTime(file); content += modifyDate; //Debug.LogFormat("{0} {1}", file, modifyDate); } return(MD5Hashing.HashString(content)); }
public ActionResult ForgetPasswordRequest(ForgotPasswordRequestModel model) { if (ModelState.IsValid) { UserProfile profile = _userProfileService.GetUser(model.UserName); if (profile != null && !profile.LockedInInd) { ForgetPasswordRequest req = new ForgetPasswordRequest() { Completed = false, ExpieryDate = DateTime.Now.AddMonths(2), GeneratedDate = DateTime.Now, RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()), UserProfileID = profile.UserProfileID }; if (_forgetPasswordRequestService.AddForgetPasswordRequest(req)) { string to = profile.Email; string subject = "Password Change Request"; string link = Request.Url.Host + "/Account/ForgetPassword/?key=" + req.RequestKey; string body = string.Format(@"Dear {1} <br /><br /> A password reset request has been submitted for your DRMFSS - CTS account. If you submitted this password reset request, please follow the following link. <br /><br /> <a href='{0}'>Please Follow this Link</a> <br /> <br /><br /> Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours. <br /><br /> Thank you,<br /> Administrator. ", link, profile.GetFullName()); try { // Read the configuration table for smtp settings. string from = _settingService.GetSettingValue("SMTP_EMAIL_FROM"); string smtp = _settingService.GetSettingValue("SMTP_ADDRESS"); int port = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT")); string userName = _settingService.GetSettingValue("SMTP_USER_NAME"); string password = _settingService.GetSettingValue("SMTP_PASSWORD"); // send the email using the utilty method in the shared dll. SendMail mail = new SendMail(from, to, subject, body, null, true, smtp, userName, password, port); return(RedirectToAction("ConfirmPasswordChange")); } catch (Exception e) { ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again."; } } else { ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again."; } } else { ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again."; } } return(View("ForgetPasswordRequest", model)); }
public static bool GenPatchPackages(string oldResDir, string newResDir) { if (!Directory.Exists(oldResDir) || !Directory.Exists(newResDir)) { return(false); } var oldResVer = GetResVersion(oldResDir); var newResVer = GetResVersion(newResDir); if (oldResVer == null || newResVer == null) { Debug.LogError("资源版本信息加载失败"); return(false); } if (oldResVer > newResVer) { Debug.LogErrorFormat("oldResVer > newResVer:{0} {1}", oldResVer, newResVer); return(false); } else if (oldResVer == newResVer) { //最新版本资源,无需生成补丁包 GenLastestPatchInfo(newResVer); return(true); } string platformName = ResManager.GetBuildPlatformName(); var oldManifest = LoadAssetBundleManifest(oldResDir + "/" + platformName); var newManifest = LoadAssetBundleManifest(newResDir + "/" + platformName); var oldBundleNames = oldManifest.GetAllAssetBundles(); var newBundleNames = newManifest.GetAllAssetBundles(); var allNameSet = new HashSet <string>(oldBundleNames); allNameSet.UnionWith(newBundleNames); var patchedNames = new List <string>(); var sb = new StringBuilder(); int index = 0; foreach (var bundleName in allNameSet) { string oldResPath = oldResDir + "/" + bundleName; string newResPath = newResDir + "/" + bundleName; bool oldResExists = File.Exists(oldResPath); bool newResExists = File.Exists(newResPath); if (oldResExists && newResExists) { //新旧版本都存在的,读取Bundle的Hash和CRC判断 var oldHash = oldManifest.GetAssetBundleHash(bundleName); var newHash = newManifest.GetAssetBundleHash(bundleName); if (oldHash != newHash) { patchedNames.Add(bundleName); sb.AppendFormat("[Patched] 新旧Hash值不一致:{0}\n{1}\n{2}\n\n", bundleName, oldHash, newHash); } else { uint oldCRC; uint newCRC; BuildPipeline.GetCRCForAssetBundle(oldResPath, out oldCRC); BuildPipeline.GetCRCForAssetBundle(newResPath, out newCRC); if (oldCRC != newCRC) { patchedNames.Add(bundleName); sb.AppendFormat("[Patched] 新旧CRC值不一致:{0}\n{1}\n{2}\n\n", bundleName, oldCRC, newCRC); } else { sb.AppendFormat("[ignored] 资源未变更:{0}\n{1}\n{2}\n\n", bundleName, newHash, newCRC); } } } else if (!oldResExists && newResExists) { patchedNames.Add(bundleName); sb.AppendFormat("[Patched] 新增版本资源:{0}\n\n", bundleName); } else if (oldResExists) { sb.AppendFormat("[ignored] 新版本资源被移除或者BundleName变更:{0}\n\n", bundleName); } else { throw new Exception(string.Format("[Error] Backup目录文件被异常删除:{0}\n\n", newResPath)); } index++; EditorUtility.DisplayProgressBar("对比Bundle包版本信息", String.Format(" {0} / {1} ", index, allNameSet.Count), index / (float)allNameSet.Count); } Debug.Log(sb); if (patchedNames.Count > 0) { string patchDir = string.Format("{0}/patch_{1}_{2}", PatchExportPath, oldResVer, newResVer); EditorUtility.DisplayProgressBar("生成补丁包中", patchDir, 0); if (Directory.Exists(patchDir)) { Directory.Delete(patchDir, true); } //AssetBundleManifest也需要拷贝 Dictionary <string, string> fileHash = new Dictionary <string, string>(); patchedNames.Add(ResManager.GetBuildPlatformName()); foreach (var patchedName in patchedNames) { string patchFile = patchDir + "/" + patchedName; CopyFile(newResDir + "/" + patchedName, patchFile); fileHash[patchedName] = SHA256Hashing.HashFile(patchFile); } string zipFile = patchDir + ".zip"; ZipTool.CompressFolder(zipFile, patchDir); string zipHash = MD5Hashing.HashFile(zipFile); long fileSize = new FileInfo(zipFile).Length; string finalZipFile = string.Format("{0}-{1}.zip", patchDir, zipHash); if (File.Exists(finalZipFile)) { File.Delete(finalZipFile); } File.Move(zipFile, finalZipFile); var patchInfo = new PatchInfo { version = oldResVer.ToString(), nextVer = newResVer.ToString(), hash = zipHash, fileSize = fileSize, fileName = Path.GetFileName(finalZipFile), fileHash = fileHash, }; string jsonPath = string.Format("{0}/{1}_{2}.json", PatchExportPath, ResourceModuleConfig.PatchInfoPrefix, oldResVer); FileExt.SaveJsonObj(patchInfo, jsonPath, false, true); Directory.Delete(patchDir, true); Debug.Log("Build Patch Package:" + finalZipFile); } else { Debug.Log("Build Patch Package Skip!!!"); } EditorUtility.ClearProgressBar(); return(true); }
public async Task <User> Login(string username, string password) { var user = await _context.Users.FirstOrDefaultAsync(u => u.Username == username && u.Password == MD5Hashing.CreateMD5(password)); if (user == null) { return(null); } return(user); }
public IActionResult Post([FromBody] Hashes text) { cuHash.Hash = MD5Hashing.CalculateMD5Hash(text.Hash); text = cuHash; return(Ok(text)); }
public ActionResult ForgetPasswordRequest(ForgetPasswordRequestModel model) { if (ModelState.IsValid) { var user = _userAccountService.GetUserDetail(model.UserName); if (user != null) { var forgetPasswordRequest = new ForgetPasswordRequest() { Completed = false, ExpieryDate = DateTime.Now.AddMonths(2), GeneratedDate = DateTime.Now, RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()), UserProfileID = user.UserProfileID //RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()), //UserAccountID = user.UserAccountId }; if (_forgetPasswordRequestService.AddForgetPasswordRequest(forgetPasswordRequest)) { string to = user.Email; string subject = "Password Change Request"; var callbackUrl = Url.Action("ForgetPassword", "Account", new { key = forgetPasswordRequest.RequestKey }, protocol: Request.Url.Scheme); //string link = "localhost:" + Request.Url.Port + "/Account/ForgetPassword/?key=" + forgetPasswordRequest.RequestKey; string body = string.Format(@"Dear {1} <br /><br /> A password reset request has been submitted for your Email account. If you submitted this password reset request, please follow the following link. <br /><br /> <a href='{0}'>Please Follow this Link</a> <br /> <br /><br /> Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours. <br /><br /> Thank you,<br /> Administrator. ", callbackUrl, user.UserName); try { // Read the configuration table for smtp settings. string from = _settingService.GetSettingValue("SMTP_EMAIL_FROM"); string smtp = _settingService.GetSettingValue("SMTP_ADDRESS"); int port = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT")); string userName = _settingService.GetSettingValue("SMTP_USER_NAME"); string password = _settingService.GetSettingValue("SMTP_PASSWORD"); // send the email using the utilty method in the shared dll. Cats.Helpers.SendMail mail = new Helpers.SendMail(from, to, subject, body, null, true, smtp, userName, password, port); ViewBag.ErrorMessage = "Email has been sent to your email Address."; TempData["ModelState"] = ViewBag.ErrorMessage; return(RedirectToAction("ConfirmPasswordChange")); } catch (Exception e) { ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again."; } } ViewBag.ErrorMessage = "Internal Error...."; } ViewBag.ErrorMessage = "Invalid User Name " + model.UserName; } return(View()); }