diff --git a/auf/django/secretquestions/models.py b/auf/django/secretquestions/models.py index 61a9353..f2ec6db 100644 --- a/auf/django/secretquestions/models.py +++ b/auf/django/secretquestions/models.py @@ -2,15 +2,18 @@ from django.db import models -from django.contrib.auth.models import get_hexdigest, check_password - - -def crypt_answer(raw): - import random - algo = 'sha1' - salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5] - hsh = get_hexdigest(algo, salt, raw) - return '%s$%s$%s' % (algo, salt, hsh) +try: + from django.contrib.auth.models import get_hexdigest, check_password + def crypt_answer(raw): + import random + algo = 'sha1' + salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5] + hsh = get_hexdigest(algo, salt, raw) + return '%s$%s$%s' % (algo, salt, hsh) +except ImportError: + from django.contrib.auth.hashers import make_password, check_password + def crypt_answer(raw): + return make_password(raw, hasher='sha1') def check_answer(raw, crypted):