Skip to content

Instantly share code, notes, and snippets.

@earonesty
Last active January 29, 2019 20:25
Show Gist options
  • Save earonesty/1023c9de69aa5ae02d83fe3baf4dd753 to your computer and use it in GitHub Desktop.
Save earonesty/1023c9de69aa5ae02d83fe3baf4dd753 to your computer and use it in GitHub Desktop.
decompose integer into hex flags
# or visit: https://earonesty.github.io/decompose_hex.html
def hex_decompose(flag):
b = bin(flag)[2:]
for i in range(len(b)):
if int(b[i]):
x = len(b) - i - 1
y = '1' + ('0' * x)
print(hex(int(y,2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment