Using xcrud data manipulation and more specifically from where it says "Database instanse In all external files you can use xcrud database instanse:", I have my table displaying using $xcrud = Xcrud::get_instance()->table('users');
.
Now the issue is that all my data is encrypted using AES_ENCRYPT
with a $salt
. I need to do an AES_DECRYPT
but unsure where or how I can go about it with xcrud
methods.
Can I even go about using the MySQL AES_DECRYPT
function purely in PHP instead and just use a callback in the functions.php
?
Edit: I've tried this method in PHP however it is displaying weird characters (���,��ŝA����,�At�nz��M�F)...
function mysql_aes_key($key)
{
$new_key = str_repeat(chr(0), 16);
for($i=0,$len=strlen($key);$i<$len;$i++)
{
$new_key[$i%16] = $new_key[$i%16] ^ $key[$i];
}
return $new_key;
}
function decrypt_info($value)
{
$key = mysql_aes_key('mysalt');
$value = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $value, MCRYPT_MODE_ECB, mcrypt_create_iv( mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_DEV_URANDOM));
return rtrim($value, "0..10");
}
function decrypt_name($value)
{
$decrypted = decrypt_info($value);
return $decrypted;
}