In RE2, it was done like that: shorturl = hashlib.md5(str(datetime.now())).hexdigest()[:9]