Ejemplo n.º 1
0
        private static string GenerateLogin(string lastName, string firstName)
        {
            Random rand       = new Random();
            string randNumber = rand.Next(0, 999).ToString();

            string login = Transliteration.Front(lastName) + "_" + Transliteration.Front(firstName[0].ToString().ToUpper());

            login += randNumber;

            return(login);
        }
Ejemplo n.º 2
0
        private static string GeneratePass(string lastName, string firstName)
        {
            const string valid     = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890фбвгдеёжзийклмнросптфхцчшщьыэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЫЬЭЮЯ";
            Random       rand      = new Random();
            string       pass      = "";
            string       finalPass = "";
            int          randNumber;
            int          charsCount = valid.Length;
            string       chunkLName = lastName[0].ToString() + lastName[1].ToString() + lastName[2].ToString();

            chunkLName = Transliteration.Front(chunkLName);
            string chunkName = firstName[0].ToString() + firstName[1].ToString() + firstName[2].ToString();

            chunkName = Transliteration.Front(chunkName);

            for (int i = 0; i < 7; i++)
            {
                randNumber = rand.Next(1, 99999);
                pass       = pass + valid[randNumber % charsCount].ToString();
            }

            randNumber = rand.Next(1, 99999);
            int stringBuildChoise = randNumber % 4;

            switch (stringBuildChoise)
            {
            case 0:
            {
                finalPass = chunkName + pass;
            }
            break;

            case 1:
            {
                finalPass = pass + chunkName;
            }
            break;

            case 2:
            {
                finalPass = chunkName + pass[0].ToString() + pass[1].ToString() + pass[2].ToString() + pass[3].ToString() + chunkLName;
            }
            break;

            case 3:
            {
                finalPass = chunkLName + pass[0].ToString() + pass[1].ToString() + pass[2].ToString() + pass[3].ToString() + chunkName;
            }
            break;
            }

            int    capitalChoise;
            string chosenCapital;
            string finalFinalPass = "";

            for (int i = 0; i < finalPass.Length; i++)
            {
                if (Char.IsLetter(finalPass[i]))
                {
                    capitalChoise = rand.Next() % 2;

                    if (capitalChoise == 0)
                    {
                        finalFinalPass = finalFinalPass + finalPass[i].ToString().ToUpper();
                    }
                    else
                    {
                        finalFinalPass = finalFinalPass + finalPass[i].ToString().ToLower();
                    }
                    continue;
                }

                finalFinalPass = finalFinalPass + finalPass[i].ToString();
            }

            return(finalFinalPass);
        }