Created
July 14, 2023 00:04
-
-
Save nick3499/b881d7d6983d8374f2cdb1bd8ab53e87 to your computer and use it in GitHub Desktop.
Generate Hexadecimal Pattern: random.randrange()
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
#!/bin/python3 | |
''' | |
generate password based on hex pattern | |
93b44021-a479-5fc2-4037-08b690031c73 | |
xxxx-xx-xx-xx-xxxxxx | |
''' | |
from random import randrange | |
patt = [4, 2, 2, 2, 6] | |
hex_sets = [] | |
for p in patt: | |
hex_sets.append(''.join([hex(randrange(0, 255))[2:] for a in range(p)])) | |
print('-'.join(hex_sets)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The purpose for this script was to generate any pattern of hexdecimal octets for specific random passwords
93b44021-a479-5fc2-4037-08b690031c73
becomes an example of a pseudo-randomly generated hex pattern for password creation but values inpatt
can be changed in order to suit any particular pattern—also add to the list; increase the number of values.xxxx-xx-xx-xx-xxxxxx
notice how this pattern example represents the actual values inpatt
, which are based on the number of octets needed, instead of the total value of hexits. In other words, the hexadecimal octeta4
contains the hexitsa
and4
.Even though
patt
contains[4, 2, 2, 2, 6]
for my original purpose, it could be changed to[4, 3, 4, 3, 6, 5]
for your purpose, for example.