# phpman > perldoc > GnuPG::Tie

## NAME
    [GnuPG::Tie::Encrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3AEncrypt/markdown) - Tied filehandle interface to encryption with the GNU Privacy Guard.

    [GnuPG::Tie::Decrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3ADecrypt/markdown) - Tied filehandle interface to decryption with the GNU Privacy Guard.

## SYNOPSIS
        use [GnuPG::Tie::Encrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3AEncrypt/markdown);
        use [GnuPG::Tie::Decrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3ADecrypt/markdown);

        tie *CIPHER, '[GnuPG::Tie::Encrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3AEncrypt/markdown)', armor => 1, recipient => 'User';
        print CIPHER <<EOF;
    This is a secret
    EOF
        local $/ = undef;
        my $ciphertext = <CIPHER>;
        close CIPHER;
        untie *CIPHER;

        tie *PLAINTEXT, '[GnuPG::Tie::Decrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3ADecrypt/markdown)', passphrase => 'secret';
        print PLAINTEXT $ciphertext;
        my $plaintext = <PLAINTEXT>;

        # $plaintext should now contains 'This is a secret'
        close PLAINTEXT;
        untie *PLAINTEXT;

## DESCRIPTION
    [GnuPG::Tie::Encrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3AEncrypt/markdown) and [GnuPG::Tie::Decrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3ADecrypt/markdown) provides a tied file handle interface to
    encryption/decryption facilities of the GNU Privacy guard.

    With [GnuPG::Tie::Encrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3AEncrypt/markdown) everything you write to the file handle will be encrypted. You can read
    the ciphertext from the same file handle.

    With [GnuPG::Tie::Decrypt](https://www.chedong.com/phpMan.php/perldoc/GnuPG%3A%3ATie%3A%3ADecrypt/markdown) you may read the plaintext equivalent of a ciphertext. This is one can
    have been written to file handle.

    All options given to the tie constructor will be passed on to the underlying GnuPG object. You
    can use a mix of options to output directly to a file or to read directly from a file, only
    remember than once you start reading from the file handle you can't write to it anymore.

## AUTHOR
    Francis J. Lacoste <<francis.lacoste@Contre.COM>>

## COPYRIGHT
    Copyright (c) 1999, 2000 iNsu Innovations Inc. Copyright (c) 2001 Francis J. Lacoste

    This program is free software; you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.

## SEE ALSO
### gpg

