public static void DecryptFileAndOutPutToFile(Stream inputStream, string outputFileName = DefaultFileName) { if (inputStream == null) { throw new ArgumentNullException(nameof(inputStream)); } if (!PrivateKeyPopulated) { throw new Exception(PrivateKeyNotPopulatedText); } Stream fOut = File.Create(outputFileName); Streams.PipeAll(DecryptStream(inputStream, PSS_PGPEncrypt.StringToStream(_privateKey), _password), fOut); fOut.Close(); }
/// <summary> /// The simplest and best way to Decrypt a stream /// Make sure you've populated PSSPGPDecrypt.PrivateKey(STRING) and Password(Optional) /// </summary> /// <param name="inputStream"></param> /// <returns>A Decrypted String</returns> public static Stream DecryptStream(Stream inputStream) { if (inputStream == null) { throw new ArgumentNullException(nameof(inputStream)); } if (!PrivateKeyPopulated) { throw new Exception(PrivateKeyNotPopulatedText); } using (var privateKeyStream = PSS_PGPEncrypt.StringToStream(_privateKey)) { return(DecryptStream(inputStream, privateKeyStream, _password)); } }