diff options
| author | Xavier Ordoquy | 2014-02-18 11:42:35 +0100 |
|---|---|---|
| committer | Xavier Ordoquy | 2014-02-18 11:42:35 +0100 |
| commit | b2f0f4fcf49d457aefc21960f62fcb8f2cf6770d (patch) | |
| tree | 9adabfaa8c2a73e9b1304f8d699a3f70f284634a /rest_framework/authtoken/models.py | |
| parent | 5ae94547bc08ade94c3f1df2223c0b8261cae59f (diff) | |
| parent | 822eb39599b248c68573c3095639a831ab6df99a (diff) | |
| download | django-rest-framework-b2f0f4fcf49d457aefc21960f62fcb8f2cf6770d.tar.bz2 | |
Merge remote-tracking branch 'reference/master' into feature/django_1_7
Diffstat (limited to 'rest_framework/authtoken/models.py')
| -rw-r--r-- | rest_framework/authtoken/models.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/rest_framework/authtoken/models.py b/rest_framework/authtoken/models.py index 024f62bf..8eac2cc4 100644 --- a/rest_framework/authtoken/models.py +++ b/rest_framework/authtoken/models.py @@ -1,5 +1,5 @@ -import uuid -import hmac +import binascii +import os from hashlib import sha1 from django.conf import settings from django.db import models @@ -34,8 +34,7 @@ class Token(models.Model): return super(Token, self).save(*args, **kwargs) def generate_key(self): - unique = uuid.uuid4() - return hmac.new(unique.bytes, digestmod=sha1).hexdigest() + return binascii.hexlify(os.urandom(20)) def __unicode__(self): return self.key |
