Example #1
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //recivers public key
            publicKeyPath = Environment.CurrentDirectory + @"\keys\reciver\pub.bpg";
            //senders private key
            privateKeyPath = Environment.CurrentDirectory + @"\keys\sender\secret.bpg";
            //pass phrase
            passPhrase = "galileo";

            PgpEncryptionKeys kes = new PgpEncryptionKeys(this.publicKeyPath, this.privateKeyPath, this.passPhrase);
            PgpEncrypt ecnFile = new PgpEncrypt(kes);
            FileInfo fileInfo = new FileInfo(Environment.CurrentDirectory + @"\exp\Шаляпин.doc");
            //FileInfo fileInfo = new FileInfo(Environment.CurrentDirectory + @"\exp\Шаляпин.doc");
            /*string newFileName = Environment.CurrentDirectory + "\\exp\\" + string.Format("{0: dd_MM_yyyy HH_mm}",
            DateTime.Now) + fileInfo.Extension;
            fileInfo.MoveTo(newFileName);*/

            string path = Environment.CurrentDirectory + "\\" + fileInfo.Name + ".bpg";
            
            using (Stream outStrm = File.Create(path))
            {   
                ecnFile.EncryptAndSign(outStrm, fileInfo);                
            }
            
        }
Example #2
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            //sender's public key
            publicKeyPath = Environment.CurrentDirectory + @"\keys\sender\pub.bpg";
            //resiver's private key
            privateKeyPath = Environment.CurrentDirectory + @"\keys\reciver\secret.bpg";
            //pass phrase
            passPhrase = "ajar";

            PgpEncryptionKeys kes = new PgpEncryptionKeys(this.publicKeyPath, this.privateKeyPath, this.passPhrase);

            PgpDecrypt decFile = new PgpDecrypt(kes);

            using (var encStream = File.OpenRead(Environment.CurrentDirectory + "\\Шаляпин.doc.bpg"))
            {
                decFile.VerifySignature(encStream, @"D:\Temp");
            }

        }
Example #3
0
        public bool proccessIncomingMsg(ref string errorReason)
        {
            if (EMsgTmpFile == null)
            {
                errorReason = "Отсутсвует файл";
                return false;
            }

            string password = "******";  //////////////***********Пароль***********////////////////////
            byte[] keyFile = new byte[] { };    //////////////***********Файл***********////////////////////

            BinaryFormatter bf = new BinaryFormatter();
            BundleFile recivedFile = (BundleFile)bf.Deserialize(EMsgTmpFile.InputStream);

            PgpEncryptionKeys _keys = new PgpEncryptionKeys("pub.gpg", password, keyFile);
            using (Stream strm = new MemoryStream(recivedFile.EncryptedSignedFile))
            {
                PgpDecrypt decryptor = new PgpDecrypt(_keys);
                decryptor.VerifySignature(strm, null);
            }

            return false;
        }
Example #4
0
        /// <summary>
        /// Instantiate a new PgpEncrypt class with initialized PgpEncryptionKeys.
        /// </summary>
        /// <param name="encryptionKeys"></param>
        /// <exception cref="ArgumentNullException">encryptionKeys is null</exception>
        public PgpEncrypt(PgpEncryptionKeys encryptionKeys)
        {
            if (encryptionKeys == null)

                throw new ArgumentNullException("encryptionKeys", "encryptionKeys is null.");

            m_encryptionKeys = encryptionKeys;
        }