2

I'm trying to use different hashers with django 1.4. I have a hasher file 'hashers.py' in my app 'accounts',

import hashlib

from pbkdf2 import pbkdf2
from django.contrib.auth.hashers import SHA1PasswordHasher
from django.utils.crypto import pbkdf2


class SHA512PasswordHasher(SHA1PasswordHasher):
    algorithm = "sha512"

and i added to settings,

PASSWORD_HASHERS = (
    'accounts.hashers.SHA512PasswordHasher',
)

I get the following exception value,

Exception Value:

hasher not found: accounts.hashers.SHA512PasswordHasher

also, if i don't have

from pbkdf2 import pbkdf2

i get the following error,

Exception Value:

Unknown password hashing algorithm 'pbkdf2_sha256'. Did you specify it in the PASSWORD_HASHERS setting?

Even when i use any of the already written hashers in the main django library. Could be a bug?

Anyway, why is my new hasher not being found. I followed what is written in the django documentation. https://docs.djangoproject.com/en/dev/topics/auth/

4

1 に答える 1

0

設定については、ハッシャーを置き換えるのではなく、リストに追加する必要があります。したがって、次のようにコーディングします。

PASSWORD_HASHERS += (
    'accounts.hashers.SHA512PasswordHasher',
)
于 2013-09-14T19:54:18.337 に答える