« lib/Perlmazing/Perlmazing/Precompile/eval_string.pm
↑ Summary
blib/lib/Perlmazing/Perlmazing/basename.pm »
| 1 | use Perlmazing qw(croak get_aes_cipher); | ||
| 2 | |||
| 3 | # Mainly ripped from Crypt::Rijndael::MySQL | ||
| 4 | sub main { | ||
| 5 | define my ($data, $key) = (shift, shift); | ||
| 6 | my $cipher = get_aes_cipher $key; | ||
| 7 | my $dec = $cipher->decrypt($data); | ||
| 8 | my $pad = ord substr $dec, -1; | ||
| 9 | croak 'Incorrect padding (wrong password or broken data?)' if substr($dec, -$pad) ne chr($pad) x $pad; | ||
| 10 | substr $dec, 0, length($dec) - $pad; | ||
| 11 | } | ||
| 12 | |||
| 13 | 1; |