MD5加密表中所有密码
我有一个名为 user 的数据库表,其中有一些列。其中一列是用户密码。
该密码未加密,我现在要做的就是自动获取该表中的所有用户和所有密码,对其进行加密,并使用新的加密密码更新表。
我能做些什么?使用 PHP 循环?或者什么?
我在这里有点迷失..
你能提供一个有效的例子吗?
所以我从表中选择密码
$query="SELECT * FROM users";
$ar=mysql_query($query) or die("Error selecting accounts: ".mysql_error());
$ac = mysql_num_rows($ar);
while($arow = mysql_fetch_array($ar)) {
$password = $arow['Password'];
}
AND.......
之后我完全迷失了。
你能帮我吗?
谢谢
I have a database table called user where I have some columns. One of these columns is the user password.
This password is not encrypted, what I have to do now is grab automatically all the users and all the passwords in that table, encrypt them, and update the table with the new encrypted passwords.
What can I do? Using a PHP loop? Or what?
I am a little bit lost here..
Could you please provide a working example?
So I select the Passwords from the Table
$query="SELECT * FROM users";
$ar=mysql_query($query) or die("Error selecting accounts: ".mysql_error());
$ac = mysql_num_rows($ar);
while($arow = mysql_fetch_array($ar)) {
$password = $arow['Password'];
}
AND.......
After that I am totally lost.
Could you help me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
输入此代码到phpMyAdmin SQL查询页面。首先登录phpMyAdmin,然后选择DB和表,然后点击“SQL”。然后您需要在字段中输入此内容并提交:
编辑
OP 想要实际的 PHP 代码:
没有比这更清晰的了。您必须确保密码字段足够大以存储 md5 哈希值。请记住,md5 哈希值的长度为 32 个字符。
Enter this code to phpMyAdmin SQL query page. First login in phpMyAdmin, then select DB and table and then click "SQL". Then you need to enter this in the field and submit:
EDIT
The OP wanted actual PHP code:
Can't get any clearer than this. You'd have to make sure that the password field is big enough to store md5 hashes. Remember that md5 hashes are 32 characters long.
DiegoP 询问如何使用 PHP 执行此操作,它来了(由于某种原因我无法在那里添加评论..)
编辑:如果想循环它使用
DiegoP asked way to do this with PHP, and here it comes (for some reason I could not add comment there..)
EDIT: If want to loop it use