Skip to content

Instantly share code, notes, and snippets.

@galvanic
Created July 14, 2014 13:27
Show Gist options
  • Select an option

  • Save galvanic/7b5a9cdfbb5e5649085a to your computer and use it in GitHub Desktop.

Select an option

Save galvanic/7b5a9cdfbb5e5649085a to your computer and use it in GitHub Desktop.
Replace x with hexdecimal values
#!/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