Beispiel #1
0
        static void Main(string[] args)
        {
            string path = @"C:\Users\T. Jezioro\Documents\Visual Studio 2015\Projects\PasswordEncryption\password.txt";
            string hash;

            string password = Gui.ReadPasswordFromUser();

            MD5 md5Hash = Md5Encryption.Md5Creat();

            hash = Md5Encryption.GetMd5Hash(md5Hash, password);

            if (IoFile.Exist(path) != true)
            {
                IoFile.WriteAll(path, hash);
                Gui.WriteLine("File created. Password saved.");
            }
            else
            {
                bool checkPassword = ComparisonUtil.CheckPassword(hash, path);
                if (checkPassword == true)
                {
                    Gui.WriteFontGreen("Password is correct");
                }
                else
                {
                    Gui.WriteFontRed("Password is NOT correct");
                }
            }
            Gui.GuiSpace();
            Gui.Write("Please press any key to close this application.");
            Console.ReadKey();
        }
Beispiel #2
0
        public static string ReadPasswordFromUser()
        {
            System.Console.Write("Please enter a password: ");
            string password = Console.ReadLine();

            Gui.GuiSpace();
            return(password);
        }