Задать вопрос

Тел: +7 965 3737 888





Use crypt instead of sha1 as password hash algorithm

<p>This snippet uses signals to replace the contrib.auth.models.User.set_password() function with one that uses <em>crypt</em> instead of <em>sha1</em> to hash the password.</p>
<p><em>Crypt</em> is of course cryptographically inferior to <em>sha1</em>, but this may be useful for interoperability with legacy systems e.g. when sharing a user authentication database with unix, a MTA etc.</p>
<p>For some reason the User class doesn't emit a class_prepared signal, which would otherwise be a better choice here. That's why I had to resort to patching each User instance separately.</p>
<p>A clean way to deploy this snippet is to place it in the models.py of an otherwise empty app, and add the app in settings.INSTALLED_APPS. The order of INSTALLED_APPS doesn't matter since we're patching instances, not classes.</p>

Вопрос полезен? Да0/Нет0

Ответы (1):

Ответ полезен? Да0/Нет0

how the last line is better than the following:

from django.contrib.auth.models import User
User.set_password = set_password_crypt