简体   繁体   English

如何使用PHP解密AES?

[英]How to decrypt AES using PHP?

I use this lib to create AES encrypt string on Android and add this string to MySQL. 我使用此在Android上创建AES加密字符串,并将此字符串添加到MySQL。

This is parameter of lib: 这是lib的参数:

在此处输入图片说明

Now I want to decrypt the String by PHP: 现在,我想通过PHP解密字符串:

This is encrypt string: 这是加密字符串:

Plaintext: a
z8OVzJvtKHPCdT6PeFoEww==(encrypt)

Then I want decrypt this string on my webserver using PHP. 然后,我想使用PHP在我的Web服务器上解密此字符串。

I use this code, but that have something wrong: 我使用此代码,但是有问题:

require "connect.php";
$sql_query = "SELECT * FROM user_info";
$result = mysqli_query($con,$sql_query); 
$name_en="";
$row = mysqli_fetch_assoc($result);
$name_en = $row['name'];
echo $name_en;
$password = "123456789";
$iv = "0000000000000000";
echo "<br/>";
echo $password;
echo "<br/>";
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'','cbc','');
mcrypt_generic_init($cipher, $password, $iv);
$decrypted = mdecrypt_generic($cipher,base64_encode($name_en));
mcrypt_generic_deinit($cipher);
echo $decrypted;

But the result is: 但是结果是:

z8OVzJvtKHPCdT6PeFoEww==
123456789
#�7��T26�r���v��u�T[|�9`��.���

Thank for advance. 感谢提前。

if it is encrypted by AES it should be decrypted by AES . 如果它是由AES加密的,则应该由AES解密。 i think there are built in functions for that aes_encrypt() and aes_decrypt() 我认为有内置函数供aes_encrypt()和aes_decrypt()使用

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

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