The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

Class::Usul::Crypt - Encryption/decryption functions

Synopsis

   use Class::Usul::Crypt qw(decrypt encrypt);

   my $args = q(); # OR
   my $args = 'salt'; # OR
   my $args = { salt => 'salt', seed => 'whiten this' };

   $args->{cipher} = 'Twofish2'; # Optionally

   my $base64_encrypted_text = encrypt( $args, $plain_text );

   my $plain_text = decrypt( $args, $base64_encrypted_text );

Description

Exports a pair of functions to encrypt/decrypt data. Obfuscates the default encryption key

Configuration and Environment

The $key can be a string (including the null string) or a hash ref with salt and seed keys. The seed attribute can be a code ref in which case it will be called with no argument and the return value used

Subroutines/Methods

decrypt

   my $plain = decrypt( $salt || \%params, $encoded );

Decodes and decrypts the $encoded argument and returns the plain text result. See the "encrypt" method

encrypt

   my $encoded = encrypt( $salt || \%params, $plain );

Encrypts the plain text passed in the $plain argument and returns it Base64 encoded. By default Crypt::Twofish2 is used to do the encryption. The optional $params->{cipher} attribute overrides this

cipher_list

   @list_of_ciphers = cipher_list();

Returns the list of ciphers supported by Crypt::CBC. These may not all be installed

default_cipher

   $ciper_name = default_cipher();

Returns Twofish2

__cipher

Lifted from Acme::Bleach this recovers the default seed for the key generator

Generates the key used by the encrypt and decrypt methods. The seed is eval'd in string context and then the salt is concatenated onto it before being passed to Class::Usul::Functions/create_token. Uses this value as the key for a Crypt::CBC object which it creates and returns

Diagnostics

None

Dependencies

Crypt::CBC
Crypt::Twofish2
Exporter
MIME::Base64

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <pjfl@cpan.org>

License and Copyright

Copyright (c) 2014 Peter Flanigan. All rights reserved

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

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE