Created
July 14, 2014 13:27
-
-
Save galvanic/7b5a9cdfbb5e5649085a to your computer and use it in GitHub Desktop.
Replace x with hexdecimal values
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
| #!/usr/bin/python | |
| import sys | |
| from itertools import product | |
| string = sys.argv[1] | |
| values = [l for l in "0123456789ABCDEF"] | |
| # replace x by hexdecimal values | |
| substrings = string.split("x") | |
| ending = substrings.pop(-1) | |
| substrings = [[s + "x"] for s in substrings] | |
| hex_ss = [[s[0].replace("x", val) for val in values] for s in substrings] | |
| combs = list(product(*hex_ss)) | |
| final = ["".join(s) + ending for s in combs] | |
| for f in final: | |
| print f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment