Last active
January 29, 2019 20:25
-
-
Save earonesty/1023c9de69aa5ae02d83fe3baf4dd753 to your computer and use it in GitHub Desktop.
decompose integer into hex flags
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
# 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