replace django.utils.hashcompat with hashlib

The compatibility modules django.utils.copycompat and django.utils.hashcompat as well as the functions django.utils.itercompat.all and django.utils.itercompat.any will be removed. The Python builtin versions should be used instead.

https://docs.djangoproject.com/en/1.4/internals/deprecation/#id3
ah, sorry about this!  I noticed it was used in the password reset flow and
this is why I initially suggested it.  Can we at least increase the key
space to something greater than the 5 character hexdigest trim?  That part
seems particularly brute-forceable :)

Cheers,

--mvv

On Thu, Sep 25, 2014 at 1:00 AM, Mateusz Sikora <notifications@github.com>
wrote:

> In invitation/models.py:
>
> > @@ -27,8 +27,8 @@ def create_invitation(self, user, email):
> >          kwargs['date_invited'] = date_invited
> >          #kwargs['groups':groups]
> >          kwargs['expiration_date'] = date_invited + datetime.timedelta(settings.ACCOUNT_INVITATION_DAYS)
> > -        salt = sha_constructor(str(random.random())).hexdigest()[:5]
> > -        kwargs['code'] = sha_constructor("%s%s%s" % (datetime.datetime.now(), salt, user.username)).hexdigest()
> > +        salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
> > +        kwargs['code'] = hashlib.sha1("%s%s%s" % (datetime.datetime.now(), salt, user.username)).hexdigest()
>
> @mvanveen <https://github.com/mvanveen> this solution has a bug -
> default_token_generation doesn't deliver unique hash, so user can't
> generate more than one invitation
>
> ```In [25]: default_token_generator.make_token(user)
> Out[25]: u'3vb-2dbbf7a23215be0ade7e'
>
> In [26]: default_token_generator.make_token(user)
> Out[26]: u'3vb-2dbbf7a23215be0ade7e'
>
> In [27]: default_token_generator.make_token(user)
> Out[27]: u'3vb-2dbbf7a23215be0ade7e'
>
>
> We need to get back to hashlib.sha1 unless you have other solution
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/joeatmatterport/django-invitation-simplified/pull/3/files#r18018948>
> .
>