Move to a common random token generation function instead of several one-offs.

(imported from commit 3217de5384088deff68fbffc6bd481c045a76817)
This commit is contained in:
Jessica McKellar
2013-08-08 10:50:58 -04:00
parent 28a4c1e971
commit 3f8dfc7b9b
3 changed files with 10 additions and 6 deletions

View File

@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import base64
import hashlib
import os
from time import sleep
from django.conf import settings
def statsd_key(val, clean_periods=False):
@@ -93,3 +96,6 @@ def log_statsd_event(name):
"""
event_name = "events.%s" % (name,)
statsd.incr(event_name)
def generate_random_token(length):
return base64.b16encode(os.urandom(length / 2)).lower()