[英]How to echo out decrypt data in PHP
First, i have use aes_encrypt
to encrypt the password 首先,我使用
aes_encrypt
加密密码
Then i have use aes_decrypt
to decrypt the password 然后我使用
aes_decrypt
解密密码
The issue is when i try to echo out the data in a table using <?php echo $row['pass'];?>
, there'll be an error 问题是当我尝试使用
<?php echo $row['pass'];?>
表中的数据时,会出现错误
"Undefined index: pass in"
“未定义的索引:传递”
SQL insert SQL插入
insert into username (userName,pass) values('$userName', aes_encrypt('$pass','k'))
插入用户名(userName,pass)值('$ userName',aes_encrypt('$ pass','k'))
SQL select SQL选择
SELECT UserNameID,userName,aes_decrypt(pass,'k') from username
从用户名中选择UserNameID,userName,aes_decrypt(pass,'k')
What went wrong? 什么地方出了错?
Don't you need to use an alias here? 您不需要在这里使用别名吗?
SELECT aes_decrypt(pass, 'k') AS pass_decrypted FROM ...
And then access it with 然后使用
echo $row['pass_decrypted'];
In your result set is the password column named as used function. 在结果集中,密码列名为使用的功能。 All you need is to set an alias of that column such as:
aes_decrypt(pass,'k') as 'pass'
: 您所需
aes_decrypt(pass,'k') as 'pass'
的就是为该列设置别名,例如: aes_decrypt(pass,'k') as 'pass'
:
SELECT UserNameID, userName, aes_decrypt(pass,'k') as pass FROM username
Your PHP code expect the column 'pass' in result set.. 您的PHP代码期望结果集中的列“通过”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.