From 736f28928e0003b27707ec6e1ecbe61534751525 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 27 Jan 2010 15:50:47 +0100 Subject: Change hash generation to a 5-digit base62 string. --- pastepy.py | 6 ++++-- 1 file 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() -- cgit v1.2.3