 <p>The smallest builtin hash I am aware of is md5</p> <pre><code>&gt;&gt;&gt; import hashlib &gt;&gt;&gt; hashlib.md5("hello worlds").digest().encode("base64") 'uWuHitcvVnCdu1Yo4c6hjQ==\n' </code></pre> <p>Low collision and short are somewhat mutually exclusive due to the <a href="http://en.wikipedia.org/wiki/Birthday_problem" rel="nofollow noreferrer">birthday paradox</a></p> <p>To make it urlsafe you need to use the function from the base64 module</p> <pre><code>&gt;&gt;&gt; import base64 &gt;&gt;&gt; base64.urlsafe_b64encode(hashlib.md5("hello world").digest()) 'XrY7u-Ae7tCTyyK7j1rNww==' </code></pre> <p>However there should be no problem storing the 16 byte md5 digest in the database in binary form.</p> <pre><code>&gt;&gt;&gt; md5bytes=hashlib.md5("hello world").digest() &gt;&gt;&gt; len(md5bytes) 16 &gt;&gt;&gt; urllib.quote_plus(md5bytes) '%5E%B6%3B%BB%E0%1E%EE%D0%93%CB%22%BB%8FZ%CD%C3' &gt;&gt;&gt; base64.urlsafe_b64encode(md5bytes) 'XrY7u-Ae7tCTyyK7j1rNww==' </code></pre> <p>You can choose either the <code>quote_plus</code> or the <code>urlsafe_b64encode</code> for your url, then decode with the corresponding function <code>unquote_plus</code> or <code>urlsafe_b64decode</code> before you look them up in the database.</p>