示例#1
0
        private static bool ValidatePassword(string input)
        {
            if (input == null || input == "" || !FileController.FileExists(".password.ini"))
            {
                return(false);
            }

            string[] fin = FileController.ReadAsString(".password.ini").Split('\n');

            if (fin.Length != 2)
            {
                return(false);
            }

            byte[] s = Convert.FromBase64String(fin[1].Trim());

            return(fin[0].Trim() == GetHashSHA256(input, s));
        }
示例#2
0
        /// <summary>
        /// Prompts for and reads the name of an input file from user.
        /// File must be a .txt extension and must live within the directory of file
        /// </summary>
        public static void UserInputFile()
        {
            string fileInputName = string.Empty;

            do
            {
                fileInputName = GetUserInput("Enter a valid input file. File must be a .txt extension and must be within debug/bin. File must also be readable.", _fileNamePattern);

                while (!FileController.FileExists(fileInputName))
                {
                    Console.WriteLine("Input file does not exist!");
                    ErrorLogFile($"Warning: User attempted to input an input file that did not exist! {DateTime.Now}");
                    fileInputName = GetUserInput("Enter a valid input file. File must be a .txt extension and must be within debug/bin. File must also be readable.", _fileNamePattern);
                }
            } while (!CheckFilePermissions(Path.GetFullPath(fileInputName)));

            _fileInputName = fileInputName;
        }