コード例 #1
0
ファイル: PgpDecryptTest.cs プロジェクト: henryb/expirepdf
        public void PgpDecryptConstructorTest()
        {
            PgpEncryptionKeys encryptionKeys = null; // TODO: Initialize to an appropriate value
            PgpDecrypt        target         = new PgpDecrypt(encryptionKeys);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
コード例 #2
0
ファイル: PgpDecryptTest.cs プロジェクト: henryb/expirepdf
        public void DecryptAndVerifyTest()
        {
            PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys("..\\..\\..\\Misc\\keys\\viewpub.txt", "..\\..\\..\\Misc\\keys\\viewpriv.txt", ""); // TODO: Initialize to an appropriate value
            PgpDecrypt        target         = new PgpDecrypt(encryptionKeys);                                                                           // TODO: Initialize to an appropriate value
            Stream            inputStream    = null;                                                                                                     // TODO: Initialize to an appropriate value
            string            outputFile     = string.Empty;                                                                                             // TODO: Initialize to an appropriate value

            target.DecryptAndVerify(inputStream, outputFile);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
コード例 #3
0
        /// <summary>
        /// Implements the SPL.Crypto DecryptAndVerify routine.
        /// </summary>
        /// <param name="encryptedFileName">Full path and file name for the ecrypted file.</param>
        /// <returns>True / False. True if the file was decrypted and written successfully.</returns>
        private bool decryptInputFile(string encryptedFileName)
        {
            bool   returnCode;
            string outputFile = extractOutputFileName(encryptedFileName);

            try
            {
                SPL.Crypto.PgpEncryptionKeys keys = new PgpEncryptionKeys(publicKeyRingPath, secretKeyRingPath, passPhrase);
                PgpDecrypt decryptor       = new PgpDecrypt(keys);
                Stream     encryptedStream = new StreamReader(encryptedFileName).BaseStream;
                decryptor.DecryptAndVerify(encryptedStream, outputFile);
                returnCode = true;
            }
            catch (Exception)
            {
                // If there was an error, we're going to eat it and just let the user know we failed.
                returnCode = false;
            }

            return(returnCode);
        }