public void GenerateCurveLockKeyPairTest() { const string expected = "MrDDGk7GYEypr93LMgJn4Av3c98fWamRKvAKbjrTEvjtz5kRxj"; const string email = "*****@*****.**"; const string password = "******"; Console.WriteLine("--- Generate CurveLock KeyPair start ---"); var zx = new Zxcvbn.Zxcvbn(); Console.WriteLine(" - E-Mail (utf8): " + email + " [" + email.Length + "]"); Console.WriteLine(" - E-Mail Entropy (~): " + zx.EvaluatePassword(email).Entropy); Console.WriteLine(" - Password (utf8): " + password + " [" + password.Length + "]"); Console.WriteLine(" - Password Entropy (~): " + zx.EvaluatePassword(password).Entropy); var keyPair = KeyGenerator.GenerateCurveLockKeyPair(email, password); Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" + keyPair.PrivateKey.Length + "]"); Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" + keyPair.PublicKey.Length + "]"); var encodedPublicKey = KeyGenerator.EncodeCurveLockPublicKey(keyPair.PublicKey); Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" + encodedPublicKey.Length + "]"); Console.WriteLine("--- Generate CurveLock KeyPair end ---"); Assert.AreEqual(expected, encodedPublicKey); }
public void GenerateBytejailKeyPairTest() { const string expected = "2PNPvrfYAQxhaGYaAzsWTYgEzymmQZ37jG2vJThBJHDcY4SABnH"; const string userInputPartOne = "*****@*****.**"; const string userInputPartTwo = "magnetometers payee induce tangibly polonaises unrestricted oilfield"; Console.WriteLine("--- Generate bytejail KeyPair start ---"); var zx = new Zxcvbn.Zxcvbn(); Console.WriteLine(" - UserInputPartOne (utf8): " + userInputPartOne + " [" + userInputPartOne.Length + "]"); Console.WriteLine(" - UserInputPartOne Entropy (~): " + zx.EvaluatePassword(userInputPartOne).Entropy); Console.WriteLine(" - UserInputPartTwo (utf8): " + userInputPartTwo + " [" + userInputPartTwo.Length + "]"); Console.WriteLine(" - UserInputPartTwo Entropy (~): " + zx.EvaluatePassword(userInputPartTwo).Entropy); var keyPair = KeyGenerator.GenerateBytejailKeyPair(userInputPartOne, userInputPartTwo); Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" + keyPair.PrivateKey.Length + "]"); Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" + keyPair.PublicKey.Length + "]"); var encodedPublicKey = KeyGenerator.EncodeBytejailPublicKey(keyPair.PublicKey); Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" + encodedPublicKey.Length + "]"); Console.WriteLine("--- Generate bytejail KeyPair end ---"); Assert.AreEqual(expected, encodedPublicKey); }
public void GenerateBytejailKeyPairExaggeratedTest() { const string expected = "2NjStPkM3Wr2JwqmH7gG7sRUhyGVG2FFewUajjbHrWRvjDtLqwB"; // Test with KeePass generated inputs: length of 1024 exclude " and \ const string userInputPartOne = "s7MgHRz?|dP@mmD7Q#Y~:m[]~Sjy7ad)t`tO&61B@o8l9p+['.V}y{L~])z{KM*:Cr8iw2t63^bpyn]b+x8Hh5#UG^gu>y1JgVj:4]NkYR<aE+T1C/3EaC9xxL#`n:=c0^_|eZm%-5T^yOM5DI9 ,XcG!Ej5=IuV0/j>bsYM'x[hQY#uwqNkm?0emxikBM$NHyzi9SLVd?E[)9x=.]d)f,]+9;;LJx|$ki|O-7PvZR/tF}9L&Hn!whdoklx+cyGiKCh=$qfXC9nuu;!21b=)as;R$%[d4[VESbTZ<tVMiZyT0|wDSCZTLT9v`QRg[6]m0Vgr]Ps@bp`J&P_4tfv:rJJ*P.z-!=]Nc07UwfUq2,C:vI1`LHrb$>ooM_S7{Lby/awngY9TMKAi[vj+V0u6'ot&gC?@6PtUP$8*iTeP`|~|)5^Y-_Nc@1]1jJO-.3+`r<BPFuDzah'H334*M^^8g;?v{9)P,=R[Uw*$D]w#oZm6yZ}c:5V^.*(F8S{?x!s#{)UL-}`VMdg:Y6Z]KE8%tjsE;Y)w+G>S@'K1Sf;]8<$`@Novad[whD.rahiJdfP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U<0jb|Thi<m]OYw[1zQo^H}#yu?W<z1[3fFTF2DgAF[(KCw1R5p R^=* 0:w#GC-@<cpIlxrU!z3#=9|ddbe)[=OUK?TB)mJ~1n+E!66==[lHuuD#voLtSF~/:>ZiPDbW)1ASkj)-+CwPAKPO:-KHNXod4c0#6kv0_@ntAp0~gUC4&uYZmMUsSiXB^+V<&1;/7q>.HR4qf!&aozAI7*HnKJs{z2DWJaR8D)>E9|2cAZ;b(_*8W_Kz;`ZIYpSK?+djw[%(fwHef$=xrk_T!z}Q81Vf3A(tj6#$teDUV@y^;|hGj A[I^YelK&yj/H5ZU~MS;hVUPOJ%GO$(LcE={`H|3R@~6GrasDK]sT*@/HD0 1?iFqh@YKr?iteSyhs&f9$^+US*MkeB)f=^n69_)1hEU~A<hK8-#MAbpzm4H>oWUx~Fk28zQfR[w!3[ -W cJSp_J "; Console.WriteLine("--- Generate bytejail KeyPair start ---"); var zx = new Zxcvbn.Zxcvbn(); Console.WriteLine(" - UserInputPartOne (utf8): " + userInputPartOne + " [" + userInputPartOne.Length + "]"); Console.WriteLine(" - UserInputPartOne Entropy (~): " + zx.EvaluatePassword(userInputPartOne).Entropy); Console.WriteLine(" - UserInputPartTwo (utf8): " + userInputPartTwo + " [" + userInputPartTwo.Length + "]"); Console.WriteLine(" - UserInputPartTwo Entropy (~): " + zx.EvaluatePassword(userInputPartTwo).Entropy); var keyPair = KeyGenerator.GenerateBytejailKeyPair(userInputPartOne, userInputPartTwo); Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" + keyPair.PrivateKey.Length + "]"); Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" + keyPair.PublicKey.Length + "]"); var encodedPublicKey = KeyGenerator.EncodeBytejailPublicKey(keyPair.PublicKey); Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" + encodedPublicKey.Length + "]"); Console.WriteLine("--- Generate bytejail KeyPair end ---"); Assert.AreEqual(expected, encodedPublicKey); }
public void GenerateMiniLockKeyPairTest() { const string expected = "Cz5bEJLKdSib9kWxkmskExaaLdRg8tVA2qsFBnfdQwkMe"; const string email = "*****@*****.**"; const string password = "******"; Console.WriteLine("--- Generate miniLock KeyPair start ---"); var zx = new Zxcvbn.Zxcvbn(); Console.WriteLine(" - E-Mail (utf8): " + email + " [" + email.Length + "]"); Console.WriteLine(" - E-Mail Entropy (~): " + zx.EvaluatePassword(email).Entropy); Console.WriteLine(" - Password (utf8): " + password + " [" + password.Length + "]"); Console.WriteLine(" - Password Entropy (~): " + zx.EvaluatePassword(password).Entropy); var keyPair = KeyGenerator.GenerateMiniLockKeyPair(email, password); Console.WriteLine(" - Private Key (hex): " + Utilities.BinaryToHex(keyPair.PrivateKey) + " [" + keyPair.PrivateKey.Length + "]"); Console.WriteLine(" - Public Key (hex): " + Utilities.BinaryToHex(keyPair.PublicKey) + " [" + keyPair.PublicKey.Length + "]"); var encodedPublicKey = KeyGenerator.EncodeMiniLockPublicKey(keyPair.PublicKey); Console.WriteLine(" - Public ID (base58): " + encodedPublicKey + " [" + encodedPublicKey.Length + "]"); Console.WriteLine("--- Generate miniLock KeyPair end ---"); Assert.AreEqual(expected, encodedPublicKey); }
//Надёжность пароля от 0 до 4 по zxcvbn public int GetPasswordEvaluation(string password) { Zxcvbn.Zxcvbn zxcvbn = new Zxcvbn.Zxcvbn(); var evaluation = zxcvbn.EvaluatePassword(password); return(evaluation.Score); //в свойстве искомая оценка надёжности }
private static int CalculateEntropy(string password) { var passwordEvaluation = _zxcvbn.EvaluatePassword(password); int entropy = (int)Math.Round(passwordEvaluation.Entropy); return(entropy); }
/// <summary> /// Show passwors summary elements according password /// </summary> private void SetPasswordSummary() { Zxcvbn.Result passwordResult = PasswordEvaluatorEngine.EvaluatePassword(txtPassword.Text); lblPasswordLengthValue.Text = string.Concat(txtPassword.Text.Length, " ch."); lblPasswordCrackTimeValue.Text = passwordResult.CrackTimeDisplay; lblPasswordEntropyValue.Text = string.Concat(Math.Round(passwordResult.Entropy), " bits"); cpbPasswordStrength.Value = passwordResult.Score + 1; cpbPasswordStrength.Text = (passwordResult.Score + 1).ToString(); switch (passwordResult.Score) { case 0: lblPasswordStrength.Text = "Very weak"; lblPasswordStrength.ForeColor = Color.Red; cpbPasswordStrength.ForeColor = Color.Red; cpbPasswordStrength.ProgressColor = Color.Red; break; case 1: lblPasswordStrength.Text = "Weak"; lblPasswordStrength.ForeColor = ControlPaint.Light(Color.Red); cpbPasswordStrength.ForeColor = ControlPaint.Light(Color.Red); cpbPasswordStrength.ProgressColor = ControlPaint.Light(Color.Red); break; case 2: lblPasswordStrength.Text = "Medium"; lblPasswordStrength.ForeColor = ControlPaint.Light(Color.Green); cpbPasswordStrength.ForeColor = ControlPaint.Light(Color.Green); cpbPasswordStrength.ProgressColor = ControlPaint.Light(Color.Green); break; case 3: lblPasswordStrength.Text = "Good"; lblPasswordStrength.ForeColor = Color.Green; cpbPasswordStrength.ForeColor = Color.Green; cpbPasswordStrength.ProgressColor = Color.Green; break; case 4: lblPasswordStrength.Text = "Strong"; lblPasswordStrength.ForeColor = Color.DarkGreen; cpbPasswordStrength.ForeColor = Color.DarkGreen; cpbPasswordStrength.ProgressColor = Color.DarkGreen; break; } }
public static bool TestPassword(string accountName, string fullName, string password) { if (!config.IsEnabled) { return(true); } var result = true; Console.WriteLine(string.Format("Password test for account '{0}'", accountName)); if (config.BlackListPath != string.Empty) { Console.WriteLine("Blacklist check"); result = result && TestBlackList(password); } if (result && config.PasswordPolicy.MinLength > 0) { Console.WriteLine("Min Length test"); result &= password.Length >= config.PasswordPolicy.MinLength; } if (result && config.PasswordPolicy.MaxLength > 0) { Console.WriteLine("Max Length Test"); result &= password.Length < config.PasswordPolicy.MaxLength; } if (result && config.PasswordPolicy.MaxConsecutiveRepeatingCharacters > 0) { Console.WriteLine("MaxConsecutiveRepeatingCharacters test"); result &= password.HasConsecutiveChars(config.PasswordPolicy.MaxConsecutiveRepeatingCharacters); } if (result) { if (config.PasswordPolicy.MinScore > 0) { Console.WriteLine("Password scrore test"); var r = Zxcvbn.EvaluatePassword(password); Console.WriteLine(string.Format("\tPassword score is {0}", r.Score)); result &= r.Score >= config.PasswordPolicy.MinScore; } } if (result && Convert.ToBoolean(config.PasswordPolicy.Denysettings & PasswordSettings.DenyGivenName)) { Console.WriteLine("DenyGivenName AD Test"); result &= TestAdAttributeValueName(accountName, "givenName", password); } if (result && Convert.ToBoolean(config.PasswordPolicy.Denysettings & PasswordSettings.DenySurname)) { Console.WriteLine("DenySurname AD Test"); result &= TestAdAttributeValueName(accountName, "sn", password); } if (result && Convert.ToBoolean(config.PasswordPolicy.Denysettings & PasswordSettings.DenyYear)) { result &= !password.Contains(DateTime.Now.Year.ToString()); } return(result); }
// The function receives a string representing a string and returns the strength of it(1-5) public static int getPasswordScore(string psw) { Zxcvbn.Zxcvbn pswEval = new Zxcvbn.Zxcvbn(); return(pswEval.EvaluatePassword(psw).Score); }
public async Task VerifyPasswords() { var accounts = await App.PwdManager.GetPasswordList(); int itemId = 0, numItems = accounts.Count, numSkip = 0; PasswordCheckDataList.Clear(); foreach (PwdListItem item in accounts) { try { if (item.SkipCheck) { numSkip++; continue; } Zxcvbn.Result result = Checker.EvaluatePassword(item.Password); bool bOld = IsPasswordToOld(item); bool bWeak = IsPasswordTooWeak(result); if (bOld || bWeak) { PasswordCheckData checkData = new PasswordCheckData { PwdId = item.Id, LastChange = item.LastPwdChangeDateTime }; if (bOld) { checkData.Issues.Add(PwdIssue.TooOld); } if (bWeak) { checkData.Issues.Add(PwdIssue.TooWeak); } checkData.StrengthData.CalcTime = result.CalcTime; checkData.StrengthData.CrackTime = result.CrackTime; checkData.StrengthData.Entropy = Math.Round(result.Entropy) - 1; checkData.StrengthData.Score = result.Score; PasswordCheckDataList.Add(checkData); } } finally { Device.BeginInvokeOnMainThread(() => { OnVerify?.Invoke(++itemId, numItems, item); }); } } LastCheck = DateTime.Now; NumberOfPassword = numItems; NumberOfSkippedPassword = numSkip; SaveCache(); }