public static void Decrypt(bool usePassword, string keyfile, string privateKey, string publicKey, string[] filePaths) { if (usePassword || !string.IsNullOrEmpty(keyfile)) { char[] password = Array.Empty <char>(); if (usePassword) { password = PasswordPrompt.EnterYourPassword(); } FileDecryptionWithPassword(password, keyfile, filePaths); } else if (!string.IsNullOrEmpty(publicKey) && !string.IsNullOrEmpty(privateKey)) { if (publicKey.EndsWith(Constants.PublicKeyExtension)) { // Use public key file FileDecryptionWithPublicKey(privateKey, publicKey, filePaths); return; } // Use public key string FileDecryptionWithPublicKey(privateKey, publicKey.ToCharArray(), filePaths); } else if (!string.IsNullOrEmpty(privateKey)) { FileDecryptionWithPrivateKey(privateKey, filePaths); } else { DisplayMessage.Error("Please either specify a (password and/or keyfile), (private key and public key), or private key."); } }
public static byte[] Decrypt(byte[] privateKey) { try { char[] password = PasswordPrompt.EnterYourPassword(); byte[] passwordBytes = Password.Hash(password); return(Decrypt(passwordBytes, privateKey)); } catch (CryptographicException) { DisplayMessage.Error("Incorrect password or the private key has been tampered with."); return(null); } }