Commit 00b18771 by Tom Christie

Merge pull request #1382 from mking/use-urandom-directly

Generate random token directly
parents 74fc6d8f f8cda8ad
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment