Apache-AutoLogin
view release on metacpan or search on metacpan
AutoLogin.pm view on Meta::CPAN
while ($fillup>0)
{
$string.=int(rand(10));
--$fillup;
}
## a a md5_hex checksum to the string.
$string.=md5_hex($string);
my $cipher = new Crypt::Rijndael $key, Crypt::Rijndael::MODE_CBC;
# encrypt the string.
$string=$cipher->encrypt($string);
return $string;
}
sub decrypt_aes {
my ($string, $key)=@_;
# keysize() is 32, but 24 and 16 are also possible
# blocksize() is 16
## The string must have 16 bytes blocks.
if (length($string) % 16 !=0)
{
return "";
}
my $cipher = new Crypt::Rijndael $key, Crypt::Rijndael::MODE_CBC;
# decrypt it
my $decrypted=$cipher->decrypt($string);
# Chop of the last 32 bytes (this is the md5 checksum)
# and calculate checksum
## Check if the string is longer than 32 bytes
if (length ($decrypted)<32)
{
( run in 0.752 second using v1.01-cache-2.11-cpan-df04353d9ac )