Crypt-FileHandle
view release on metacpan or search on metacpan
Crypt-FileHandle version 0.02
=============================
This package creates a tied FileHandle that automatically encrypts or
decrypts data using the provided cipher. The FileHandle returned from
new() can be treated like a normal FileHandle. All encrypting,
decrypting, and buffering is completely transparent to the caller.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
lib/Crypt/FileHandle.pm view on Meta::CPAN
while(<$fh>) {
print $_;
}
close($fh);
=head1 DESCRIPTION
This package creates a tied FileHandle that automatically encrypts or
decrypts data using the provided cipher. The FileHandle returned from
new() can be treated like a normal FileHandle. All encrypting,
decrypting, and buffering is completely transparent to the caller.
=head1 CIPHER METHODS
This package generally supports ciphers compliant with Crypt::CBC,
including CryptX ciphers. The cipher provided to new() must support
at least the methods listed below, but no other methods are utilized
by this package. Refer to Crypt::CBC for more information on these
methods. Even though it is not recommended, a custom home-made cipher
object can be used if it supports these methods.
lib/Crypt/FileHandle.pm view on Meta::CPAN
Called when print(), printf(), or syswrite() is called on the tied
FileHandle returned from new(). Each method will encrypt the data and
write it to the real FileHandle based on the provided cipher. Note
that syswrite() is always utilized to write to the real FileHandle
regardless of the method called.
The number of encrypted bytes written to the real FileHandle may not
be the same as the number of cleartext bytes processed, especially if
a full block of data has not yet been provided. WRITE() will return
the number of cleartext bytes processed, which keeps the encryption
transparent to the caller.
=item F<READLINE()>
=item F<READ()>
=item F<GETC()>
Called when readline() (or <>), sysread(), or getc() is called on the
tied FileHandle returned from new(). Each method will read data from
the real FileHandle and decrypt it based on the provided cipher. Note
that sysread() is always utilized to read from the real FileHandle
regardless of the method called. Data is always read in blocks of
READSIZE bytes. Any data that is read and decrypted but not returned
is stored in an internal buffer to be utilized by future read calls.
READ() will return the number of cleartext bytes processed and not
the actual number of bytes read from the real FileHandle, which keeps
the decryption transparent to the caller.
=item F<TELL()>
Called when tell() is called on the tied FileHandle returned from
new(). Returns the number of cleartext bytes processed through the
tied FileHandle. It does not return the position of the real
FileHandle, which may differ because of the encryption. The logical
position of the data is returned as if a normal FileHandle was used,
which keeps the encryption and decryption transparent to the caller.
=item F<CLOSE()>
Called when close() is called on the tied FileHandle returned from
new(). It closes the real FileHandle. If the real FileHandle was
opened for writing, it calls finish() on the cipher object to
complete the encryption prior to closing the real FileHandle.
=item F<FILENO()>
( run in 0.276 second using v1.01-cache-2.11-cpan-0a6323c29d9 )