Пример #1
0
 protected string RetString(GetString dlg, int NeededLength)
 {
     string Retme = "";
     dlg.Text = "Password must be longer than " + NeededLength + " chars";
     if (dlg.ShowDialog() == DialogResult.OK) {
         if (dlg.Password.Length > NeededLength) {
             Retme = dlg.Password;
         }
         else {
             MessageBox.Show("Password must be longer than " + NeededLength + " chars");
             dlg.ClearPass();
             Retme = RetString(dlg);
         }
     }
     return Retme;
 }
Пример #2
0
 protected string PromptForBCryptHashGeneration()
 {
     string Original="",Retme = "";
     GetString dlg = new GetString();
     dlg.Text = "Enter Password >20 chars";
     dlg.ShowDialog();
     if (dlg.DialogResult == DialogResult.OK) {
         if (dlg.Password.Length > 20) {
             Retme = dlg.Password;
         }
         else {
             MessageBox.Show("Password must be longer than 20 chars");
             dlg.ClearPass();
             Retme = RetString(dlg);
         }
         string salt = BCrypt.Net.BCrypt.GenerateSalt(12);//4096 iterations
         Original = Retme;
         Retme = BCrypt.Net.BCrypt.HashPassword(Retme, salt);
         bool Check = BCrypt.Net.BCrypt.Verify(Original, Retme);
         Retme = Retme.TrimStart("$2a$12$".ToArray());
         if (Check == false) throw new Exception("BCrypt: original string failed verification check against hash.");
     }
     return Retme;
 }