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 reference with salt and seed keys. The seed attribute can be a code reference in which case it will be called with no argument and the return value used

Lifted from Acme::Bleach the default seed for the key generator has been whitened and included in this source file

The seed is eval'd in string context and then the salt is concatenated onto it before being passed to create token. Uses this value as the key for a Crypt::CBC object

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

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) 2016 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