Last active
August 16, 2022 00:42
-
-
Save Purrrpley/674164635868f9d40b146947b57990e1 to your computer and use it in GitHub Desktop.
Random Hex
This file contains 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
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