NAME
Crypt::CBCeasy - Easy things make really easy with Crypt::CBC
SYNOPSIS
use Crypt::CBCeasy;
IDEA::encipher($my_key, "plain-file", "crypted-file");
$plain_text = DES::decipher($my_key, \*CRYPTO_FILE);
$crypted = Blowfish::encipher($my_key, \*PLAIN_SOCKET);
ABSTRACT
This module is just a helper for Crypt::CBC to make simple and usual jobs just one-liners.
The current version of the module is available at:
http://base.dux.ru/guest/fno/perl/
DESCRIPTION
This module creates encipher()
and decipher()
functions in DES::, IDEA:: and Blowfish:: namespaces (the last one works only if your Crypt::CBC is 1.22 or later). So, the total is 6 functions neither of which is imported.
All functions take 3 parameters:
1 - en/decryption key
2 - source
3 - destination
Sources could be: existing file path, scalar (just a string that would be encrypted), opened filehandle, any object that inherits from filehandle, for example IO::File or FileHandle object, and socket.
Destinations could be any of the above except scalar, because we can not distinguish between scalar and output file name here.
Well, it's easier to look at the examples:
($fh
vars here are IO::Handle, IO::File or FileHandle objects, variables of type "GLOB", "GLOB" refs or sockets)
IDEA::encipher( $my_key, "in-file", "out-file" );
IDEA::encipher( $my_key, *IN, "out-file" );
IDEA::encipher( $my_key, \*IN, "out-file" );
IDEA::encipher( $my_key, $fh_in, "out-file" );
IDEA::encipher( $my_key, "in-file", *OUT );
IDEA::encipher( $my_key, "in-file", \*OUT );
IDEA::encipher( $my_key, "in-file", $fh_out );
IDEA::encipher( $my_key, *IN, *OUT );
IDEA::encipher( $my_key, \*IN, \*OUT );
IDEA::encipher( $my_key, $fh_in, $fh_out );
IDEA::encipher( $my_key, $plain_text, "out-file" );
IDEA::encipher( $my_key, $plain_text, *OUT );
IDEA::encipher( $my_key, $plain_text, \*OUT );
IDEA::encipher( $my_key, $plain_text, $fh_out );
any of the above will work and do what was expected.
In addition there is a 2-argument version that returns it's result as scalar:
$crypted_text = IDEA::encipher( $my_key, $plain_text );
$crypted_text = IDEA::encipher( $my_key, "in-file" );
$crypted_text = IDEA::encipher( $my_key, *IN );
$crypted_text = IDEA::encipher( $my_key, \*IN );
$crypted_text = IDEA::encipher( $my_key, $fh );
All the same is implemented for decipher()
and for DES and Blowfish.
All functions croak on errors (such as "input file not found"), so if you want to trap errors use them inside the eval{}
block and check $@
.
Sure IDEA:: functions will work only if you have Crypt::IDEA installed, DES:: - if you have Crypt::DES, Blowfish:: - if you have Crypt::Blowfish and Crypt::CBC is version 1.22 or above.
Note that all filehandles are used in binmode
whether you claimed them binmode
or not. On Win32 for example this will result in CRLF's in $plain_text after
$plain_text = DES::decipher($my_key, "crypted_file");
if "crypted_file" was created by
DES::encipher($my_key, "text_file", "crypted_file");
If the filehandle was used before - it's your job to rewind it to the beginning and/or close.
INSTALLATION
As this is just a plain module no special installation is needed. Put it into the /Crypt subdirectory somewhere in your @INC. Though the standard
Makefile.PL
make
make test
make install
procedure is provided. In addition
make html
will produce the HTML-docs.
This module requires
Crypt::CBC at least 1.20 by Lincoln Stein, lstein@cshl.org
one or more of
Crypt::IDEA, Crypt::DES, Crypt::Blowfish available from CPAN
CAVEATS
This module has been created and tested in a Win95 environment. Although I expect it to function correctly on any other system, that fact has not been confirmed.
CHANGES
0.21 Mon Mar 6 07:28:41 2000 - first public release
TODO
Any suggestions are much appreciated.
BUGS
Please report.
VERSION
This man page documents "Crypt::CBCeasy" version 0.21.
March 6, 2000.
AUTHOR
Mike Blazer, blazer@mail.nevalink.ru
http://base.dux.ru/guest/fno/perl/
SEE ALSO
Crypt::CBC
COPYRIGHT
Copyright (C) 2000 Mike Blazer.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.