Crypt-CBC

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

      $ciphertext = $cipher->encrypt_hex($plaintext)
      $plaintext  = $cipher->decrypt_hex($ciphertext)

    These are convenience functions that operate on ciphertext in a
    hexadecimal representation. encrypt_hex($plaintext) is exactly
    equivalent to unpack('H*',encrypt($plaintext)). These functions can be
    useful if, for example, you wish to place the encrypted in an email
    message.

  filehandle()
    This method returns a filehandle for transparent encryption or
    decryption using Christopher Dunkle's excellent Crypt::FileHandle
    module. This module must be installed in order to use this method.

    filehandle() can be called as a class method using the same arguments as
    new():

      $fh = Crypt::CBC->filehandle(-cipher=> 'Blowfish',
                                   -pass  => "You'll never guess");

    or on a previously-created Crypt::CBC object:

README  view on Meta::CPAN

       $cbc = Crypt::CBC->new(-cipher=> 'Blowfish',
                              -pass  => "You'll never guess");
       $fh  = $cbc->filehandle;

    The filehandle can then be opened using the familiar open() syntax.
    Printing to a filehandle opened for writing will encrypt the data.
    Filehandles opened for input will be decrypted.

    Here is an example:

      # transparent encryption
      open $fh,'>','encrypted.out' or die $!;
      print $fh "You won't be able to read me!\n";
      close $fh;

      # transparent decryption
      open $fh,'<','encrypted.out' or die $!;
      while (<$fh>) { print $_ }
      close $fh;

  get_initialization_vector()
      $iv = $cipher->get_initialization_vector()

    This function will return the IV used in encryption and or decryption.
    The IV is not guaranteed to be set when encrypting until start() is
    called, and when decrypting until crypt() is called the first time.

lib/Crypt/CBC.pm  view on Meta::CPAN

  $plaintext  = $cipher->decrypt_hex($ciphertext)

These are convenience functions that operate on ciphertext in a
hexadecimal representation.  B<encrypt_hex($plaintext)> is exactly
equivalent to B<unpack('H*',encrypt($plaintext))>.  These functions
can be useful if, for example, you wish to place the encrypted in an
email message.

=head2 filehandle()

This method returns a filehandle for transparent encryption or
decryption using Christopher Dunkle's excellent L<Crypt::FileHandle>
module. This module must be installed in order to use this method.

filehandle() can be called as a class method using the same arguments
as new():

  $fh = Crypt::CBC->filehandle(-cipher=> 'Blowfish',
                               -pass  => "You'll never guess");

or on a previously-created Crypt::CBC object:

lib/Crypt/CBC.pm  view on Meta::CPAN

   $cbc = Crypt::CBC->new(-cipher=> 'Blowfish',
                          -pass  => "You'll never guess");
   $fh  = $cbc->filehandle;

The filehandle can then be opened using the familiar open() syntax.
Printing to a filehandle opened for writing will encrypt the
data. Filehandles opened for input will be decrypted.

Here is an example:

  # transparent encryption
  open $fh,'>','encrypted.out' or die $!;
  print $fh "You won't be able to read me!\n";
  close $fh;

  # transparent decryption
  open $fh,'<','encrypted.out' or die $!;
  while (<$fh>) { print $_ }
  close $fh;

=head2 get_initialization_vector()

  $iv = $cipher->get_initialization_vector()

This function will return the IV used in encryption and or decryption.
The IV is not guaranteed to be set when encrypting until start() is



( run in 0.427 second using v1.01-cache-2.11-cpan-0a6323c29d9 )