# HG changeset patch # User Jeff Hammel # Date 1290220524 28800 # Node ID 3c193788a0dbed56562096a1def04f65e7131f82 # Parent 93cc3245bf2b727bf87783476b962d3ba2f6d482 add a script to create a random url hash diff -r 93cc3245bf2b -r 3c193788a0db python/urlhash.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/urlhash.py Fri Nov 19 18:35:24 2010 -0800 @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +""" +return a random URL hash +""" + +import random +import urllib + +chars = [ chr(i) for i in range(0,255) ] +allowed = [ urllib.quote_plus(i) for i in chars + if urllib.quote_plus(i) in chars ] + +def urlhash(len=10): + chars = random.sample(allowed, len) + string = ''.join(chars) + return urllib.quote_plus(string) + +if __name__ == '__main__': + print urlhash()