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); }
public string CopyFileCommand(CopyCommandInfo c) { try { var srcByte = LoadFileInMemory(c.SourceFile); if (IsFileFromWindowsFileSystem(c.DestinationFile)) { File.WriteAllBytes(c.DestinationFile, srcByte); return(SFS_COMMAND_MESSAGE_ONE_FILE_COPIED); } else { var fi = _sFsManager.AddFile(c.DestinationFile, srcByte); if (fi == null) { Console.WriteLine(SFS_COMMAND_ERR_COPYING_FILE); } else { if (_sFsManager.UpdateFileSystem()) { return(SFS_COMMAND_MESSAGE_ONE_FILE_COPIED); } } } } catch (System.Exception ex) { } finally { _sFsManager.Clean(); } return(SFS_COMMAND_ERR_ZERO_FILE_COPIED); }
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); }