Hàm tạo mật khẩu ngẩu nhiên - funtion random password



public static string RandomPassword(int number)
{
     var chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
     var password = string.Empty;
     var random = new Random();
     for (var i = 0; i < number; i++)
     {
         var x = random.Next(1, chars.Length);
         if (!password.Contains(chars.GetValue(x).ToString()))
         {
                    password += chars.GetValue(x);
         }
         else
         {
              i--;
          }
     }

     return password;
}

Hàm tạo mật khẩu ngẩu nhiên - funtion random password
Share To:

laptrinhvien

Post A Comment:

0 comments so far,add yours