Skip to content

Instantly share code, notes, and snippets.

@0atman
Last active December 20, 2015 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0atman/6054206 to your computer and use it in GitHub Desktop.
Save 0atman/6054206 to your computer and use it in GitHub Desktop.
from hashlib import sha1
import uuid
import hmac
def generate_key(self):
"""
Lifted from:
https://github.com/toastdriven/django-tastypie/blob/master/tastypie/models.py#L46
"""
return hmac.new(str(uuid.uuid4()), digestmod=sha1).hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment