WordPress MD5 密码
我需要通过 PHP 脚本或 MySQL 将用户插入到 Wordpress 博客中,并且我有一个纯文本密码。我想我可以做这样的事情:
$query = "INSERT INTO $new_db.wp_users (user_login, user_pass, user_nicename)
select user_email, md5(user_password), user_name from $source_db.users";
但是密码看起来都与现在的 Wordpress 密码不同。所有密码都以 $P$B
开头
,读起来说有盐...有没有办法将 test123 这样的密码转换成 Wordpress 期望的加密密码?
I need to insert users into a Wordpress blog via a PHP script or MySQL, and I have a plain text password. I thought I could do something like this:
$query = "INSERT INTO $new_db.wp_users (user_login, user_pass, user_nicename)
select user_email, md5(user_password), user_name from $source_db.users";
But the passwords all look different from what the Wordpress passwords look like now. All the passwords all start with $P$B
From reading it says there is a salt... is there a way to take a password like test123 and turn it into the encrypted password that Wordpress expects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
最明智的解决方案就是使用相关的 WordPress 函数 (wp_generate_password) 本身。
但是,如果这不是一个选项,您可以简单地提取
wp_generate_password
函数(位于 /wp-includes/pluggable.php 中)和相关支持函数。The most sensible solution would simply be to use the relevant WordPress function (wp_generate_password) itself.
However, if this isn't an option, you could simply extract the
wp_generate_password
function (it's in /wp-includes/pluggable.php) and relevant support functions.Wordpress 使用 phpass 哈希,这与 MD5 不同。
Wordpress uses phpass hashing, which is different from MD5.
创建密码的最简单方法是...
正确的电子邮件。
不要忘记从另一个帐户复制“wp_capability”和“wp_user_level”。
The easiest way to create the password is ...
correct email.
Don't forget to copy a "wp_capabilities" and a "wp_user_level" from another account.
该函数将执行您所描述的转换密码的操作:
您需要从
source_db
中选择它,在 PHP 中对其进行转换,然后将其插入到new_db
中。This function will do what you described to transform the password:
You'll need to select it from
source_db
, transform it in PHP, then insert it intonew_db
.WordPress 过去使用 MD5 密码,现在仍然可以。将密码设置为 MD5 哈希值应该可以正常工作。当每个用户第一次登录时,WordPress 将根据现在使用的更强的安全性重新哈希其密码。
WordPress used to use MD5 passwords, and still can. Setting the passwords as MD5 hashes should work fine. As each user logs in for the first time, WordPress will rehash their password based on the stronger security it now uses.