Skip to main content

Useful password hasher for django sites with drupal components

Project description

Django-Drupal Password Hasher is a simple package created to hash Drupal 7 passwords with the prefix ‘drupal’.

Taken from https://djangosnippets.org/snippets/3030/

Installation typically looks like:

pip install Django-drupal-password-hasher

Typical usage in a python script looks like:

from djangodrupalpasswordhasher import drupal_password_hasher

hasher = DrupalPasswordHasher()
salt = hasher.salt()
password = "foobar"
encoded_password = hasher.encode(password, salt)

In a django project, change the settings file to look like:

PASSWORD_HASHERS = (
    'djangodrupalpasswordhasher.drupal_password_hasher.DrupalPasswordHasher',
)

And user authentication continues as normal:

from django.contrib.auth.models import User

...

user = User(first_name='foo', last_name='bar', email='foobar@foobar.com')
user.set_password("some_random_password")
user.save()

Note: Django uses the first entry in the PASSWORD_HASHERS section of your settings file for user authentication by default. If you have other password hashers but want to use this one, make sure it is the first entry in the list.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Django-Drupal-Password-Hasher-0.1.1.tar.gz (15.9 kB view details)

Uploaded Source

File details

Details for the file Django-Drupal-Password-Hasher-0.1.1.tar.gz.

File metadata

File hashes

Hashes for Django-Drupal-Password-Hasher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b9f0812bb7ddf12ec8f1bd11b7d52efd40c098bc25804f6ad370ba446f0aa33
MD5 74d236ecea8c563dfaf5fdda19929c7a
BLAKE2b-256 b228f269494b6b4dd67a7463d33befe34a9865f24f07a40f86b291cb11ed4c6b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page