Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 private static byte[] DecryptKey(KeyProviderQueryContext ctx)
 {
     return(Gpg.Decrypt(GetAuxFile(ctx)).GetBuffer());
 }