Class::Usul::Crypt - Encryption/decryption functions
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 );
Exports a pair of functions to encrypt/decrypt data. Obfuscates the default encryption key
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
$key
my $plain = decrypt( $salt || \%params, $encoded );
Decodes and decrypts the $encoded argument and returns the plain text result. See the "encrypt" method
$encoded
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
$plain
$params->{cipher}
@list_of_ciphers = cipher_list();
Returns the list of ciphers supported by Crypt::CBC. These may not all be installed
$ciper_name = default_cipher();
Returns Twofish2
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
encrypt
decrypt
eval
Class::Usul::Functions/create_token
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
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
To install Class::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Usul
CPAN shell
perl -MCPAN -e shell install Class::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.