示例#1
0
        static bool GeneratePrivateKeyPublicKey(string pw)
        {
            var ok = false;

            Console.Clear();
            ConsoleEx.TitleBar(0, "Generate new private/public key", ConsoleColor.Yellow, ConsoleColor.DarkBlue);
            Console.Clear();
            ConsoleEx.TitleBar(0, "Generate Private/Public Key", ConsoleColor.Yellow, ConsoleColor.DarkBlue);
            var keyInfo = ConsoleEx.Question(3, "Re generate the private key and publick key Y)es N)o", new List <char> {
                'Y', 'N'
            });

            if (keyInfo == 'N')
            {
                return(ok);
            }

            keyInfo = ConsoleEx.Question(3, "Are you sure you want to generate Private/Public Key Y)es N)o", new List <char> {
                'Y', 'N'
            });
            if (keyInfo == 'N')
            {
                return(ok);
            }

            ConsoleEx.WriteLine(0, 4, "Formatting...", ConsoleColor.Yellow);
            var ppk = new PrivatePublicKeyHelper(true);

            if (!_sfsManager.Format())
            {
                ConsoleEx.WriteLine(0, 3, "Format failed", ConsoleColor.Red);
            }

            ConsoleEx.WriteLine(0, 5, "Loading and saving files...", ConsoleColor.Yellow);
            var privatek = _sfsManager.AddFile("PrivateKey");

            privatek.SetContentAsString(ppk.PrivateKey);
            var publicK = _sfsManager.AddFile("PublicKey");

            publicK.SetContentAsString(ppk.PublicKey);
            var readmeTxt = _sfsManager.AddFile("ReadMe.txt");

            readmeTxt.SetContentAsString(LoremIpsum);
            var rr = _sfsManager.UpdateFileSystem();

            if (rr)
            {
                Console.WriteLine(string.Format("Keys were generated"), ConsoleColor.Cyan);
                ok = ReloadFileSystem(pw, ppk);
            }
            else
            {
                Console.WriteLine(string.Format("Error generating the keys"), ConsoleColor.Red);
            }

            Pause();
            return(ok);
        }
示例#2
0
        static bool FormatAndInitDisk()
        {
            var ok = false;

            Console.Clear();
            ConsoleEx.TitleBar(0, "Format and initialization", ConsoleColor.Yellow, ConsoleColor.DarkBlue);
            var keyInfo = ConsoleEx.Question(3, "Format and initialize disk Y)es N)o", new List <char> {
                'Y', 'N'
            });

            if (keyInfo == 'N')
            {
                return(ok);
            }

            ConsoleEx.WriteLine(0, 4, "Formatting...", ConsoleColor.Yellow);
            if (!_sfsManager.Format())
            {
                ConsoleEx.WriteLine(0, 3, "Format failed", ConsoleColor.Red);
                return(false);
            }

            ConsoleEx.WriteLine(0, 5, "Loading and saving files...", ConsoleColor.Yellow);
            _sfsManager.AddFile(@".\files\Readme.txt");
            _sfsManager.AddFile(@".\files\Shadow.jpg");
            var rr = _sfsManager.UpdateFileSystem();

            if (rr)
            {
                Console.WriteLine(string.Format("Keys were generated"), ConsoleColor.Cyan);
                ok = ReloadFileSystem();
            }
            else
            {
                Console.WriteLine(string.Format("Error generating the keys"), ConsoleColor.Red);
            }

            Pause();
            return(ok);
        }