For some reason, using DBI's bind parameter feature for the below AES key is causing a query to fail to find any rows.
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect('dbi:mysql:database=thedb;host=localhost');
my $aes_key = 'X`ku@wC_BI\SgY[S%/<iaB>&VXd5zDA+';
print length($aes_key), "\n";
my $test = $dbh->selectrow_hashref("SELECT COUNT(*) FROM users WHERE id = ?\
AND AES_DECRYPT(enc_pass, '$aes_key') IS NOT NULL", undef, 1);
print $test->{'COUNT(*)'}, "\n";
$test = $dbh->selectrow_hashref("SELECT COUNT(*) FROM users WHERE id = ?\
AND AES_DECRYPT(enc_pass, ?) IS NOT NULL", undef, 1, $aes_key);
print $test->{'COUNT(*)'}, "\n";
Output:
32
1
0
I see there's an escaped "S" in $aes_key
, but it doesn't appear to have any impact on the variable since \S
isn't a valid escape sequence in Perl. I do suspect that or something similar is the problem, though.