From 2e1f63b03825da5e6e406c6978ba87af509ca86e Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Wed, 5 Jan 2011 17:40:55 +0100 Subject: [PATCH] Use Django's md5_constructor for backwards compatibility. --- social_auth/backends.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/social_auth/backends.py b/social_auth/backends.py index 374ffe3..362eea3 100644 --- a/social_auth/backends.py +++ b/social_auth/backends.py @@ -2,12 +2,12 @@ Authentication backeds for django.contrib.auth AUTHENTICATION_BACKENDS setting """ from os import urandom -from hashlib import md5 from openid.extensions import ax, sreg from django.conf import settings from django.contrib.auth.backends import ModelBackend +from django.utils.hashlib import md5_constructor from .models import UserSocialAuth from .conf import OLD_AX_ATTRS, AX_SCHEMA_ATTRS @@ -67,7 +67,7 @@ class SocialAuthBackend(ModelBackend): """ def get_random_username(): """Return hash from random string cut at 30 chars""" - return md5(str(urandom(10))).hexdigest()[:30] + return md5_constructor(str(urandom(10))).hexdigest()[:30] if getattr(settings, 'SOCIAL_AUTH_FORCE_RANDOM_USERNAME', False): username = get_random_username() -- 2.39.5