'Convert PHP mcrypt_decrypt in a MySQL query

I'm doing an analysis of an old MySQL database. In it, some of the column types are of blob type. When I checked the front end (written in PHP), apparently those blobs were being decoded using this method when being showed on the frontend:

$crypttext = $this->safe_b64decode($value);
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->skey, $crypttext, MCRYPT_MODE_ECB, $iv);
return trim($decrypttext);

I'm trying to do a select statement against the column and get the decryptedtext in my query.

Any idea of how to do it ?

Thank you

P.S. I have the $key value as well



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source