Skip to content

Instantly share code, notes, and snippets.

@martijnberger
Created April 12, 2021 06:43
Show Gist options
  • Save martijnberger/d73d7384847cd036246615259737c30a to your computer and use it in GitHub Desktop.
Save martijnberger/d73d7384847cd036246615259737c30a to your computer and use it in GitHub Desktop.
Generate mongoDB-ish hash
import os
import time
import binascii
def generate():
timestamp = "{:x}".format(int(time.time()))
rest = binascii.b2a_hex(os.urandom(8)).decode("ascii")
return timestamp + rest
generate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment