Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

NAME

Util::Medley::Crypt - Class for simple encrypt/descrypt of strings.

VERSION

version 0.037

SYNOPSIS

my $key = 'abcdefghijklmnopqrstuvwxyz';
my $str = 'foobar';
my $crypt = Util::Medley::Crypt->new;
#
# positional
#
my $encryptedStr = $crypt->encryptStr($str, $key);
my $decryptedStr = $crypt->decryptStr($encryptedStr, $key);
#
# named pair
#
my $encryptedStr = $crypt->encryptStr(
str => $str,
key => $key
);
my $decryptedStr = $crypt->decryptStr(
str => $encryptedStr,
key => $key
);

DESCRIPTION

This class provides a thin wrapper around Crypt::CBC.

All methods confess on error.

ATTRIBUTES

key (optional)

Key to use for encrypting/decrypting methods when one isn't provided through the method calls.

type: Str
env var: MEDLEY_CRYPT_KEY

METHODS

decryptStr

Decrypts the provided string.

usage:
my $decryptedStr = $crypt->decryptStr($encryptedStr, $key);
my $decryptedStr = $crypt->decryptStr(
str => $encryptedStr,
[ key => $key ]
);
args:
str [Str]

String you wish to decrypt.

key [Str]

Key that was used to encrypt the string.

encryptStr

Encrypts the provided string.

usage:
my $encryptedStr = $crypt->encryptStr($str, $key);
my $encryptedStr = $crypt->encryptStr(
str => $str,
[ key => $key ]
);
args:
str [Str]

String you wish to encrypt.

key [Str] (optional)

Key used to encrypt the string.