public ActionResult GeneratePassword(PasswordGeneration passwordGeneration) { var generatedPassword = new GeneratedPassword { Value = passwordGenerator.GeneratePassword(passwordGeneration.DomainName, passwordGeneration.MasterPassword, passwordGeneration.PasswordLength, passwordGeneration.HashFunction, passwordGeneration.CharacterSpace) }; return(Json(generatedPassword)); }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); return; } _instance = this; // DontDestroyOnLoad(this.gameObject); this.readTextAssetIntoList(this.easyBadPasswordsText, this.easyBadPasswords); this.readTextAssetIntoList(this.easyGoodPasswordsText, this.easyGoodPasswords); this.readTextAssetIntoList(this.mediumBadPasswordsText, this.mediumBadPasswords); this.readTextAssetIntoList(this.mediumGoodPasswordsText, this.mediumGoodPasswords); this.readTextAssetIntoList(this.hardBadPasswordsText, this.hardBadPasswords); this.readTextAssetIntoList(this.hardGoodPasswordsText, this.hardGoodPasswords); this.passwordChecker = new Zxcvbn.Zxcvbn(); }
public void ReadFile(string filename) { string strMaxPasswordAge = ParameterServices.MaxPasswordAge.ToString(); //modify by meaw change maximum password length to parameter and set unuse symbol for generate password PasswordGeneration passwordGeneration = new PasswordGeneration(ParameterServices.MinPasswordLength, ParameterServices.MaxPasswordLength, false, true, true, true, false); Encoding inputEnc = Encoding.GetEncoding("windows-874"); using (FileStream fs = new FileStream(filename, FileMode.Open)) { string s; int lineNo = 0; using (StreamReader sr = new StreamReader(fs)) { s = sr.ReadLine(); while (s != null) { lineNo++; if (lineNo != 1) { if (!String.IsNullOrEmpty(s)) { try { string[] ss = s.Split('|'); if (ss.Length >= 21) { string password = passwordGeneration.Create(); int errors = 0; TmpSuUser tmpSuUser = new TmpSuUser(); if (IsRequireField(ss[3].TrimEnd(), "EmployeeCode", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo)) { tmpSuUser.EmployeeCode = ss[3].TrimEnd(); } else { errors++; } tmpSuUser.CompanyCode = ss[46].TrimEnd(); tmpSuUser.CostCenterCode = ss[42].TrimEnd(); tmpSuUser.PayrollCostCenter = ss[121].TrimEnd(); tmpSuUser.LocationCode = ss[44].TrimEnd(); if (IsRequireField(ss[106].TrimEnd(), "UserName", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo)) { tmpSuUser.UserName = ss[106].TrimEnd(); } else { errors++; } tmpSuUser.Password = Encryption.Md5Hash(password); tmpSuUser.PasswordExpiryDate = DateTime.Now.AddDays(int.Parse(strMaxPasswordAge)); if (IsRequireField(ss[0].TrimEnd(), "PeopleID", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo)) { tmpSuUser.PeopleID = ss[0].TrimEnd(); } else { errors++; } if (IsRequireField(ss[5].TrimEnd() + " " + ss[6].TrimEnd(), "EmployeeName", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo)) { tmpSuUser.EmployeeName = ss[5].TrimEnd() + " " + ss[6].TrimEnd(); } else { errors++; } tmpSuUser.SectionName = ss[31].TrimEnd(); tmpSuUser.PersonalLevel = ss[53].TrimEnd(); tmpSuUser.PersonalDescription = ss[54].TrimEnd(); tmpSuUser.PersonalGroup = ss[53].TrimEnd(); tmpSuUser.PersonalLevelGroupDescription = ss[54].TrimEnd(); tmpSuUser.PositionName = ss[16].TrimEnd(); tmpSuUser.SupervisorName = ss[73].TrimEnd(); //tmpSuUser.LocationCode = ss[12].TrimEnd(); //validate phone no tmpSuUser.PhoneNo = ss[100].TrimEnd(); if (tmpSuUser.PhoneNo.Length > 20) { tmpSuUser.PhoneNo = tmpSuUser.PhoneNo.Substring(0, 19); } if (!string.IsNullOrEmpty(ss[62])) { tmpSuUser.HireDate = IsDate(ss[62].TrimEnd(), "HireDate", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo); } if (!string.IsNullOrEmpty(ss[65])) { tmpSuUser.TerminateDate = IsDate(ss[65].TrimEnd(), "TerminateDate", ss[0].TrimEnd(), ss[106].TrimEnd(), lineNo); } tmpSuUser.ApprovalFlag = convertApprovalFlag(ss[52].TrimEnd()); tmpSuUser.Email = ss[99].TrimEnd(); tmpSuUser.FromEHr = true; tmpSuUser.Active = true; tmpSuUser.isNewUser = false; tmpSuUser.OldPassword = password; tmpSuUser.LineNumber = lineNo; if (!string.IsNullOrEmpty(ss[110].TrimEnd())) { tmpSuUser.VendorCode = ss[110].TrimEnd(); } if (errors > 0) { s = sr.ReadLine(); continue; } else { Factory.TmpSuUserService.AddUser(tmpSuUser); } } else { Console.WriteLine("Invalid file format"); } } catch (Exception ex) { Console.WriteLine("Line No:" + lineNo + " => Error : " + ex.ToString()); } } } s = sr.ReadLine(); } } } }
private void OpenGeneratePassword(object sender, RoutedEventArgs e) { PasswordGeneration genPassword = new PasswordGeneration(); genPassword.Show(); }