Last active
September 24, 2019 09:09
-
-
Save sujith3g/059052243bbff5893479e2b0db59c274 to your computer and use it in GitHub Desktop.
Generate a Meteor-style object ID from python for use in MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def genMeteorID(length=17): | |
UNMISTAKABLE_CHARS = "23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz" | |
randomString = "" | |
for i in range(length): | |
randomString += random.choice(UNMISTAKABLE_CHARS) | |
return randomString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment