コード例 #1
0
ファイル: ProductsController.cs プロジェクト: CTKB1997/PGP
        /// <summary>
        /// Convert an byte[] parameter to string after decode (decrypt)
        /// </summary>
        /// <param name="kObj">have byte[] parameter </param>
        /// <returns></returns>

        #region Convert
        private string Convert(KeyObj kObj)
        {
            Stream output = PGPDecrypt.Decrypt(kObj.kByte, privateKeyPath, pwd);
            string later  = GenerateStringFromStream(output);

            return(later);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: fauser/PgpCryptography
        static void Main(string[] args)
        {
            if (args.Length != 4)
            {
                System.Console.WriteLine("Arguments: Path to encrypted file, Output path, Path to private key, passphrase");
                return;
            }

            if (!PathValidation.ValidateFilePath(args[0]))
            {
                return;
            }
            if (!PathValidation.ValidateDirectoryPath(args[1]))
            {
                return;
            }
            if (!PathValidation.ValidateFilePath(args[2]))
            {
                return;
            }

            string path        = Path.GetFullPath(args[0]); //@"c:\test\MyTest.txt";
            string outputPath  = Path.GetFullPath(args[1]); //@"c:\temp";
            string privKeypath = Path.GetFullPath(args[2]); //@"c:\test\keyPrivate.txt";

            PgpDecryptionKeys decryptionKeys = new PgpDecryptionKeys(privKeypath, args[3]);
            PGPDecrypt        test           = new PGPDecrypt(decryptionKeys);

            using (FileStream fs = File.Open(path, FileMode.Open))
            {
                test.decrypt(fs, outputPath);
                fs.Close();
            }
        }
コード例 #3
0
        /// <summary>
        /// The decryption.
        /// </summary>
        private void Decryption()
        {
            #region PGP Decryption

            PGPDecrypt.Decrypt(@"D:\Keys\EncryptData.txt", @"D:\Keys\PGPPrivateKey.asc", @"P@ll@m@lli", @"D:\Keys\OriginalText.txt");
            this.InfoListBox.Items.Add("Decryption Done");

            #endregion
        }
コード例 #4
0
        public async void Decryption()
        {
            #region PGP Decryption

            PGPDecrypt.Decrypt("D:\\Keys\\2018-06-08-15-13-23-INPUT-12469390.txt", @"D:\Keys\PGPPrivateKey.asc", "P@ll@m@lli", "D:\\Keys\\OriginalText.txt");

            Console.WriteLine("Decryption Done");

            #endregion
        }
コード例 #5
0
        public async void Decryption()
        {
            #region PGP Decryption

            PGPDecrypt.Decrypt("D:\\Keys\\EncryptData.txt", @"D:\Keys\PGPPrivateKey.asc", "P@ll@m@lli", "D:\\Keys\\OriginalText.txt");

            Console.WriteLine("Decryption Done");

            #endregion
        }
コード例 #6
0
ファイル: ICryptoStreamer.cs プロジェクト: ardasovvadim/ibar
        public byte[] Decrypt(byte[] encData)
        {
            using (MemoryStream outputStream = new MemoryStream())
            {
                using (MemoryStream inputStream = new MemoryStream(encData))
                {
                    inputStream.Position = 0;
                    using (Stream keyStream = GetDecryptionKey())
                    {
                        PGPDecrypt.Decrypt(inputStream, keyStream, _passPhrase, outputStream);
                    }
                }

                return(outputStream.ToArray());
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: CTKB1997/PGP
        static void Main(string[] args)
        {
            Random rnd    = new Random();
            int    rndInt = rnd.Next(0, 20000000);

            Byte[] ss = System.IO.File.ReadAllBytes(@"D:\Keys\2018-06-08-13-49-18-OUTPUT-3284217.txt");
            //Console.WriteLine(ss);
            string fileName = directory + "2018-06-08-13-49-18-OUTPUT-3284217.txt";

            //string fileName = directory + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-OUTPUT-" + rndInt.ToString(), CultureInfo.InvariantCulture) + ".txt";
            System.IO.File.WriteAllBytes(fileName, ss);
            Console.WriteLine(fileName);
            //var item = JsonConvert.DeserializeObject<Product>(requestParam.ToString());
            //string item = JsonConvert.DeserializeObject<String>(requestParam.ToString());
            //PGPDecrypt.Decrypt("D:\\Keys\\EncryptData.txt", @"D:\Keys\PGPPrivateKey.asc", "P@ll@m@lli", "D:\\Keys\\OriginalText.txt");
            Stream output = PGPDecrypt.Decrypt(fileName, privateKeyPath, pwd);
            string later  = GenerateStringFromStream(output);

            Console.WriteLine(later);
            var item = JsonConvert.DeserializeObject <Product>(later);
        }
コード例 #8
0
        public void Decryption()
        {
            PGPDecrypt.Decrypt(filePath + "\\" + encryptedFile, _keyRingHome + "\\" + secretKeyRingFilename, secretKeyRingPassphrase, filePath + "\\" + outputFile, _keyRingHome + "\\" + publicKeyRingFilename);

            Console.WriteLine("Decryption Done");
        }