简体   繁体   English

显示加密的数据库字段

[英]Display Encrypted Database Fields

I have finally made the long overdue jump from PHP 5.6 to PHP 7.3 and upgraded mySQL to MariaDB.我终于实现了从 PHP 5.6 到 PHP 7.3 的姗姗来迟的跳跃,并将 mySQL 升级到了 MariaDB。 All seems to be working other than one app.除了一个应用程序之外,所有似乎都在工作。 I'm not bothered about trying to repair the code in the script, but I'd love to get a dump of the data.我不介意尝试修复脚本中的代码,但我很想获得数据的转储。

Two of the fields are encrypted.其中两个字段是加密的。 I have the salt and encryption code, but I don't have the skills to be able to run a query that displays the encoded fields.我有盐和加密代码,但我没有能够运行显示编码字段的查询的技能。

This is the encode function from the application:这是应用程序的编码功能:

function encode($string) {
$config     = &singleton::get(__NAMESPACE__ . '\config');
$error      = &singleton::get(__NAMESPACE__ . '\error');

$level      = $config->get('encryption_level');
$key        = $config->get('encryption_key');

switch ($level) {
    case 2:
        $error->create(array('type' => 'security_error', 'message' => 'Encode function cannot be used for this database security level.'));
    break;
    default:
        $encrypted  = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));      
    break;
}

return $encrypted;

} }

Can anyone help?任何人都可以帮忙吗?

We read the documentation :我们阅读了文档:

mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] ) : string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] ) : string

mcrypt_decrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] ) : string mcrypt_decrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] ) : string

so if this encrypts it:所以如果这对其进行加密:

$encrypted  = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)));      

this will hopefully decrypt it:这将有望解密它:

$decrypted = base64_decode(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), $encrypted, MCRYPT_MODE_CBC, md5(md5($key)) ));

Thanks for the advice everyone.谢谢大家的建议。 In the meantime I took a different approach, and loaded up a local PHP 5.6 instance on Wampserver and hey presto!与此同时,我采用了不同的方法,在 Wampserver 上加载了一个本地 PHP 5.6 实例,嘿嘿! The application lives again.应用程序再次生效。

Now I can extract the information I need using cut'n'paste with the luxury of a working app.现在,我可以使用 cut'n'paste 和工作应用程序的奢华来提取我需要的信息。 Not perfect, but it works.不完美,但它有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM