Пример #1
0
        public string DecryptText(string path)
        {
            var fullPath = GetPasswordFilePath(path);

            if (!File.Exists(fullPath))
            {
                throw new ArgumentException($"The password file \"{fullPath}\" does not exist.");
            }

            if (PinentryFixEnabled)
            {
                pinentryWatcher.BumpPinentryWindow();
            }
            return(Gpg.Decrypt(fullPath));
        }
Пример #2
0
        public void TestEncryptDecrypt()
        {
            Gpg g = new Gpg(GPG_BINARY_PATH);

            g.LocalUser  = GPG_LOCAL_USER_KEY;
            g.Recipient  = GPG_RECIPIENT_KEY;
            g.Passphrase = GPG_PASSWORD;

            byte[]       data       = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04 };
            MemoryStream cleartext  = new MemoryStream(data);
            MemoryStream ciphertext = new MemoryStream();

            g.Encrypt(cleartext, ciphertext);

            ciphertext.Position = 0;
            MemoryStream cleartext2 = new MemoryStream();

            g.Decrypt(ciphertext, cleartext2);

            assertEqual(cleartext, cleartext2);
        }
Пример #3
0
 private static byte[] DecryptKey(KeyProviderQueryContext ctx)
 {
     return(Gpg.Decrypt(GetAuxFile(ctx)).GetBuffer());
 }