Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
Created August 22, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinmehall/685c86d8c0717007922b to your computer and use it in GitHub Desktop.
Save kevinmehall/685c86d8c0717007922b to your computer and use it in GitHub Desktop.
import os
def randid():
r = bytearray(os.urandom(16))
s = ""
for i in range(24):
idx, pos = (i*5)/8, (i*5)%8
val = ((r[idx] >> pos) | (r[idx+1] << (8-pos))) & ((1<<5)-1)
s += "0123456789ABCDFGHJKLMNPQRSTVWXYZ"[val]
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment