Skip to content

Instantly share code, notes, and snippets.

@Purrrpley
Last active August 16, 2022 00:42
Show Gist options
  • Save Purrrpley/674164635868f9d40b146947b57990e1 to your computer and use it in GitHub Desktop.
Save Purrrpley/674164635868f9d40b146947b57990e1 to your computer and use it in GitHub Desktop.
Random Hex
import random
def get_random_hex(length):
return hex(random.getrandbits(length*4))[2:].zfill(length)
# >>> print(get_random_hex(8))
# 062e08db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment