using System;
using SKGL;
using System.Threading;

namespace LicenceGenerator
{
    class Program
    {
        private static int intResponse;
        private static readonly string privateKey = "TRZzjAutdtA542aeQj";
        private static readonly string accessPassword = "fullIMPACT77@@@";

        static void Main(string[] args)
        {
            PasswordCheck();

            Console.WriteLine("-- Licence file generator for MicronSync --");
            Console.WriteLine("How many licences would you like to generate?");
            string response = Console.ReadLine();

            if (!Int32.TryParse(response, out intResponse))
            {
                Console.WriteLine("Please enter a valid number!");
                Main(null);
            }

            GenerateLicences();

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }

        private static void PasswordCheck()
        {
            Console.WriteLine("Please enter the access password:");
            string response = Console.ReadLine();

            if (response != accessPassword)
            {
                Console.WriteLine("Incorrect password. Goodbye!");
                Console.ReadLine();
                Environment.Exit(0);
            }

            Console.Clear();
        }

        private static void GenerateLicences()
        {
            Generate gen = new Generate();

            for (int i = 0; i < intResponse; i++)
            {
                Thread.Sleep(100);
                gen.secretPhase = privateKey;
                Console.WriteLine(gen.doKey(0));
            }
        }
    }
}
