[英]Wordpress password how to compare user password to wordpress user table password?
[英]Wordpress User Password Data as Plaintext / Export Wordpress User Password to Django
我的wordpress中有大约900个用户,我正在将这些用户数据导出到将使用Django的新平台中。
我的问题是,如何将这些用户的密码导出为纯文本? 如果我做不到,我想将其存储在新数据库的“ old_password”字段中,但是我想知道如何将文本与old_password“匹配”? 因为我的计划是,当用户登录时,我将尝试查找具有相同电子邮件和哈希密码的用户,但我不知道Wordpress使用哪种类型的哈希函数以及Python Django中该函数的等效形式。
使用此库, https://github.com/jmoswalt/wp-to-django-users
基本上,您添加了django的功能,以重新散列旧的wordpress密码,以便您的旧wordpress用户现在可以在新的django网站上使用相同的旧密码
在您的django项目的settings.py文件中,添加以下内容:
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
'hashers_passlib.phpass',
)
然后重新哈希密码,即可完成操作。
from django.contrib.auth.hashers import get_hasher
hasher = get_hasher('phpass')
user.password = hasher.from_orig(user.password)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.