Beispiel #1
0
        public void PermLetter_SymbolIsPermutated()
        {
            Setup();

            char input     = 'a';
            char encrypted = enigma.PermLetter(input);

            Assert.AreNotEqual(input, encrypted);
        }
        } //E>b9k_-x#xoO

        public static string PassWordExample(string password)
        {
            if (password.Length <= 20 && password.Length >= 3)
            {
                Enigma enigma = new Enigma(new char[] { password[0], password[password.Length - 1], password[password.Length / 2] });

                Random rand         = new Random(DateTime.Now.Millisecond);
                int    fillerLength = 20 - password.Length;
                char   fillerLetter = (char)rand.Next(33, 123);
                string fillerString = "";
                for (int i = 0; i < fillerLength; i++)
                {
                    fillerString += fillerLetter;
                }

                string encodedPassword = enigma.PermString(password + fillerString);
                char   endCipher       = (char)(33 + password.Length);
                encodedPassword += enigma.PermLetter(endCipher);

                Console.WriteLine("What is stored in database:");
                Console.WriteLine(encodedPassword);

                return(encodedPassword);
            }

            return(null);
        }