Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  CRYPT::CBCEASY (3)

.ds Aq ’


Crypt::CBCeasy - Easy things make really easy with Crypt::CBC



 use Crypt::CBCeasy; # !!! YOU can not require this module !!!

 IDEA::encipher($my_key, "plain-file", "crypted-file");

 $plain_text = DES::decipher($my_key, \*CRYPTO_FILE);

 $crypted = Blowfish::encipher($my_key, \*PLAIN_SOCKET);


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 CPAN.


After you call this module as

  use Crypt::CBCeasy IMPORT-LIST;

it creates the encipher() and decipher() functions in all namespaces (packages) listed in the IMPORT-LIST.

Without the IMPORT-LIST it creates these 2 functions in the <B>DES::B>, <B>IDEA::B> and <B>Blowfish::B> namespaces by default to stay compatible with the previous versions that were capable to handle only these 3 ciphers.

You have to install Crypt::CBC v. 1.22 or later to work with Blowfish.

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 etc.

Here’s the list of the ciphers that could be called via the Crypt::CBCeasy interface today (in fact the same modules that are Crypt::CBC compatible):

  Cipher          CPAN module

  DES             Crypt::DES
  IDEA            Crypt::IDEA
  Blowfish        Crypt::Blowfish
  Twofish2        Crypt::Twofish2
  DES_PP          Crypt::DES_PP
  Blowfish_PP     Crypt::Blowfish_PP
  Rijndael        Crypt::Rijndael
  TEA             Crypt::TEA

Note that cipher names are case sensitive in the IMPORT-LIST, so blowfish will give an error. Type them exactly as they are written in the correspondent underlying modules.

Both encipher() and decipher() functions take 3 parameters:

  1 - en/decryption key
  2 - source
  3 - destination

The sources could be: an existing file, a scalar (just a string that would be encrypted), an opened filehandle, any other object that inherits from the 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)

<B>IDEA::encipher(B> $my_key, in-file, out-file <B>);B>

<B>IDEA::encipher(B> $my_key, *IN, out-file <B>);B>

<B>IDEA::encipher(B> $my_key, \*IN, out-file <B>);B>

<B>IDEA::encipher(B> $my_key, $fh_in, out-file <B>);B>

<B>IDEA::encipher(B> $my_key, in-file, *OUT <B>);B>

<B>IDEA::encipher(B> $my_key, in-file, \*OUT <B>);B>

<B>IDEA::encipher(B> $my_key, in-file, $fh_out <B>);B>

<B>IDEA::encipher(B> $my_key, *IN, *OUT <B>);B>

<B>IDEA::encipher(B> $my_key, \*IN, \*OUT <B>);B>

<B>IDEA::encipher(B> $my_key, $fh_in, $fh_out <B>);B>

<B>IDEA::encipher(B> $my_key, $plain_text, out-file <B>);B>

<B>IDEA::encipher(B> $my_key, $plain_text, *OUT <B>);B>

<B>IDEA::encipher(B> $my_key, $plain_text, \*OUT <B>);B>

<B>IDEA::encipher(B> $my_key, $plain_text, $fh_out <B>);B>

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 = <B>IDEA::encipher(B> $my_key, $plain_text <B>);B>

$crypted_text = <B>IDEA::encipher(B> $my_key, in-file <B>);B>

$crypted_text = <B>IDEA::encipher(B> $my_key, *IN <B>);B>

$crypted_text = <B>IDEA::encipher(B> $my_key, \*IN <B>);B>

$crypted_text = <B>IDEA::encipher(B> $my_key, $fh <B>);B>

All the same is possible for any of the ciphers in the IMPORT-LIST.

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 the $@.

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.


As this is just a plain module no special installation is needed. Put it into the /Crypt subdirectory somewhere in your @INC. The standard

 make test
 make install

procedure is provided. In addition

 make html

will produce the HTML-docs.

This module requires

Crypt::CBC by Lincoln Stein, v.1.20 or later.

one or more of

Crypt::IDEA, Crypt::DES, Crypt::Blowfish, Crypt::Blowfish_PP, Crypt::Twofish2, Crypt::DES_PP or other Crypt::CBC compatible modules.


This module has been created and tested in a Win95/98/2000Pro environment with Perl 5.004_02 and ActiveState ActivePerl build 618. I expect it to function correctly on other systems too.


 0.21   Mon Mar  6 07:28:41 2000  -  first public release

 0.22   Sun Feb 18 13:11:59 2001
        A horrible BUG was found by Michael Drumheller <>
        In fact 0.21 was ALWAYS using DES despite of the desired cipher.
        And the test is modified so that this will never happen again.

        Now you can define the list of ciphers that are compatible
        with Crypt::CBC in the import list.
        You can not call this module with the "require" statement. This
        is incompatible with the older versions.

  0.23  Crypt::Rijndael 0.02 compatibility was approved.
        Tests are some more complex now.

  0.24  Crypt::TEA 1.01 by Abhijit Menon-Sen <> is checked
        and approved.


Any suggestions are much appreciated.


Please report.


This man page documents Crypt::CBCeasy version 0.24

February 18, 2001


Mike Blazer,




Copyright (C) 2000-2001 Mike Blazer.

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 CBCEASY (3) 2001-04-07

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.