public static void ValidateFileEncryptionInput(bool encryption, char[] password, string keyfilePath, string[] filePaths) { if (filePaths != null) { bool keyfileSelected = !string.IsNullOrEmpty(keyfilePath); if (encryption == true && password == null && keyfileSelected == false) { const int words = 6; password = PasswordGenerator.GenerateRandomPassphrase(words, true, true); DisplayRandomPassphrase(password); } if ((password != null && password.Length >= 8) || keyfileSelected) { CallEncryption(encryption, password, keyfilePath, filePaths); } else { Console.WriteLine("Error: Please enter a password (8+ characters long) or select/generate a keyfile."); } } else { Console.WriteLine("Error: Please select files/folders to encrypt/decrypt."); } }
public static void GenerateRandomPassphrase(int length) { if (length >= 4 && length <= 20) { char[] passphrase = PasswordGenerator.GenerateRandomPassphrase(length, true, true); Console.WriteLine(passphrase); Utilities.ZeroArray(passphrase); } else { Console.WriteLine("Error: Invalid number of words. Randomly generated passphrases must be between 4-20 words."); } }