我想加密数据并在解密后获取它。我正在使用
AES_ENCRYPT and AES_DECRYPT functions of MYSQL
我试了很多指出错误,但我无法理解为什么我会得到无响应。请告诉我哪里出错了
这是我的代码
<?php
//Turn off all error reporting
//error_reporting(0);
ini_set ("display_errors", "1");
error_reporting(E_ALL);
if(($_GET['action'])&&($_GET['username'])&&($_GET['key'])) {
$select = $_GET['action'];
$username =$_GET['username']; //no default
$key= $_GET['key'];
if($key=='dYrtr3GGPVuhSMvm'){
if($select=='select'){
/* connect to the db */
$connect = mysqli_connect('localhost','root','')or die("Couldn't connect to database!");
mysqli_select_db($connect,'easy_sign') or die ("Couldn't find database");
$key="x1y2z3";
$query ="SELECT *, AES_DECRYPT(path, '$key') AS decrypted_path, AES_DECRYPT(filename, '$key') AS decrypted_name FROM origin WHERE username ='$username' ";
$result = mysqli_query($connect,$query);
$numrows=mysqli_num_rows($result);
if($numrows!==0)
{
$post = array();
while($row = mysqli_fetch_array($result))
{
$post['path'] = $row['decrypted_path'];
$post['filename'] = $row['decrypted_name'];
$post['username'] = $row['username'];
$post['date'] = $row['date'];
}
header('Content-type: application/json');
echo json_encode($post);
}
}
}
}
?>