Skip to content

Instantly share code, notes, and snippets.

@hdknr
Created October 14, 2009 10:24
Show Gist options
  • Save hdknr/209960 to your computer and use it in GitHub Desktop.
Save hdknr/209960 to your computer and use it in GitHub Desktop.
def generate_random_codes(self):
"""
Used to generate random key/secret pairings.
Use this after you've added the other data in place of save().
"""
key = generate_random(length=KEY_SIZE)
secret = generate_random(length=SECRET_SIZE)
while Consumer.objects.filter(key__exact=key, secret__exact=secret).count():
secret = generate_random(length=SECRET_SIZE)
self.key = key
self.secret = secret
self.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment