Django 1.7 md5crypt

Django 1.7 md5crypt,django,authentication,md5,Django,Authentication,Md5,我对django场景仍然很陌生,仍在学习基础知识,并将介绍一些关于如何解决这个问题的建议 我的任务是将django网站从1.3升级到1.7,并将应用程序从1.3转移到1.7,我能够创建一个测试项目,使用默认身份验证将身份验证转到管理页面,但是当我查看1.3版本的auth_user表时,我注意到身份验证是在md5_crypt中以以下格式进行的:md5crypt$salt$hash,我尝试使用passlib 1.6.2,但没有成功,在数据库密码字段中将md5crypt更改为md5_crypt 有人能

我对django场景仍然很陌生,仍在学习基础知识,并将介绍一些关于如何解决这个问题的建议

我的任务是将django网站从1.3升级到1.7,并将应用程序从1.3转移到1.7,我能够创建一个测试项目,使用默认身份验证将身份验证转到管理页面,但是当我查看1.3版本的auth_user表时,我注意到身份验证是在md5_crypt中以以下格式进行的:md5crypt$salt$hash,我尝试使用passlib 1.6.2,但没有成功,在数据库密码字段中将md5crypt更改为md5_crypt


有人能告诉我如何将md5crypt密码功能添加到默认配置的django 1.7项目中的正确方向吗?

我似乎已经解决了这个问题,我在django 1.3机器的md5crypt中找到了一个要加密的模块,然后转到我的django/usr/local/lib/python2.7/dist-packages/django/contrib/auth/hasher.py文件,并定义了一个新的hasher类:

#imported md5crypt.py module that I moved to /usr/local/lib/python2.7/dist-packages/django/contrib/auth/
from django.contrib.auth import md5crypt

class MD5CryptPasswordHasher(BasePasswordHasher):
"""
The Salted MD5crypt password hashing algorithm
"""
algorithm = "md5crypt"

def encode(self, password, salt):
    assert password is not None
    assert salt and '$' not in salt
    cryptedpassword = md5crypt.md5crypt(force_bytes(password), force_bytes(salt))
    cryptedpassword = cryptedpassword.split('$',2)[2]
    #change from $1$ to md5crypt$
    return "%s$%s" % (self.algorithm, cryptedpassword)

def verify(self, password, encoded):
    algorithm, salt, hash = encoded.split('$', 2)
    assert algorithm == self.algorithm
    encoded_2 = self.encode(password, salt)
    return constant_time_compare(encoded, encoded_2)

def safe_summary(self, encoded):
    algorithm, salt, hash = encoded.split('$', 2)
    assert algorithm == self.algorithm
    return OrderedDict([
        (_('algorithm'), algorithm),
        (_('salt'), mask_hash(salt, show=2)),
        (_('hash'), mask_hash(hash)),
    ])
我的密码哈希设置.py:

PASSWORD_HASHERS=(
 'django.contrib.auth.hashers.MD5CryptPasswordHasher',
 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
 'django.contrib.auth.hashers.BCryptPasswordHasher',
 'django.contrib.auth.hashers.SHA1PasswordHasher',
 'django.contrib.auth.hashers.MD5PasswordHasher',
 'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',
 'django.contrib.auth.hashers.CryptPasswordHasher',
)

我无法与您共享模块md5crypt.py,因为出于安全原因,我没有该模块的权限。

1.3项目如何使用md5crypt?1.3项目中的密码\u哈希设置是什么?