summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-01-27 15:50:47 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-01-27 15:50:47 +0100
commit736f28928e0003b27707ec6e1ecbe61534751525 (patch)
tree37cf3fb68e8dc94881bbe17c91500cd327662b37
parentd6337a93a34836fd479839697d9d82c045b01da2 (diff)
Change hash generation to a 5-digit base62 string.
-rw-r--r--pastepy.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pastepy.py b/pastepy.py
index 570aef6..c24fcf8 100644
--- a/pastepy.py
+++ b/pastepy.py
@@ -1,8 +1,10 @@
-import templates, pygments, cgi, db, datetime, hashlib, settings, os, mimetypes, Cookie
+import templates, pygments, cgi, db, datetime, settings, os, mimetypes, Cookie, random
from pygments import highlight
from pygments.lexers import get_all_lexers, get_lexer_by_name
from pygments.formatters import HtmlFormatter
+base62_alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+
class Paste(object):
def __init__(self):
lexers = dict([(x[0], x[1][0]) for x in get_all_lexers()])
@@ -69,7 +71,7 @@ class Paste(object):
title = mp['title'].value
text = mp['text'].value
- hash = hashlib.md5(datetime.datetime.utcnow().ctime() + self.environ['REMOTE_ADDR']).hexdigest()
+ hash = ''.join(random.choice(base62_alphabet) for x in xrange(5))
try:
session = db.Session()