public static void PerformBenchmark(int delayPerFile) { Console.WriteLine(); RunBenchmark(delayPerFile); KryptorSettings.SaveSettings(); // Deallocate RAM for Argon2 GC.Collect(); Console.WriteLine(); Console.WriteLine($"Argon2 will use a memory size of {Invariant.ToString(Globals.MemorySize / Constants.Mebibyte)} MiB. This value can be changed in the settings."); }
public static void DisplaySettings(string[] arguments) { if (arguments == null) { Console.WriteLine($"memory-encryption: {Globals.MemoryEncryption}"); Console.WriteLine($"anonymous-rename: {Globals.AnonymousRename}"); Console.WriteLine($"overwrite-files: {Globals.OverwriteFiles}"); Console.WriteLine($"memory-size: {Globals.MemorySize / Constants.Mebibyte} MiB"); Console.WriteLine($"iterations: {Globals.Iterations}"); Console.WriteLine(); Console.WriteLine("Use --settings [setting name] [value] to change a setting."); } else { KryptorSettings.EditSettings(arguments); } }
public static void EncryptByteArray(ref byte[] byteArray) { try { if (Globals.MemoryEncryption == true && byteArray != null) { byteArray = SealedPublicKeyBox.Create(byteArray, _keyPair.PublicKey); } } catch (Exception ex) when(ExceptionFilters.MemoryEncryptionExceptions(ex)) { Globals.MemoryEncryption = false; KryptorSettings.SaveSettings(); Logging.LogException(ex.ToString(), Logging.Severity.Bug); DisplayMessage.Error(ex.GetType().Name, "Memory encryption has been disabled due to an exception. This is a bug - please report it."); } }
private void OnExecute() { Console.WriteLine(); KryptorSettings.ReadSettings(); if (Encrypt) { bool encryption = true; char[] password = ConvertPassword(); CommandLine.ValidateFileEncryptionInput(encryption, password, Keyfile, Arguments); } else if (Decrypt) { bool encryption = false; char[] password = ConvertPassword(); CommandLine.ValidateFileEncryptionInput(encryption, password, Keyfile, Arguments); } else if (!string.IsNullOrEmpty(GenerateKeyfile)) { CommandLine.CreateKeyfile(GenerateKeyfile); } else if (GeneratePassword != 0) { CommandLine.GenerateRandomPassword(GeneratePassword); } else if (GeneratePassphrase != 0) { CommandLine.GenerateRandomPassphrase(GeneratePassphrase); } else if (GenerateKeys) { CommandLine.GenerateRecipientKeyPair(); } else if (EncryptPassword) { bool encryption = true; CommandLine.ValidatePasswordSharingInput(encryption, Arguments); } else if (DecryptPassword) { bool encryption = false; CommandLine.ValidatePasswordSharingInput(encryption, Arguments); } else if (Settings) { CommandLine.DisplaySettings(Arguments); } else if (Benchmark) { CommandLine.SelectBenchmarkMode(); } else if (Documentation) { CommandLine.OpenDocumentation(); } else if (SourceCode) { CommandLine.OpenSourceCode(); } else if (CheckForUpdates) { CommandLine.UpdateCheck(displayUpToDate: true); } else if (About) { CommandLine.DisplayAbout(); } else if (ErrorLog) { CommandLine.OpenKryptorDirectory(); } else { Console.WriteLine("Error: Unrecognized option. Specify --help for a list of available options and commands."); } }