Skip to content

Instantly share code, notes, and snippets.

Created August 25, 2015 18:39
What would you like to do?
mod_uid hex to cookie
import base64
import struct
import sys
def main():
Sample input: 'F705D40AACC48C54571D9D7A02CAFA59'
yields sample output: 'CtQF91SMxKx6nR1XWfrKAg=='
x = sys.argv[1]
l1 = int(x[:8],16)& 0xffffffff
l2 = int(x[8:16],16) & 0xffffffff
l3 = int(x[16:24],16) & 0xffffffff
l4 = int(x[24:],16) & 0xffffffff
s = struct.pack("<IIII", l1, l2, l3, l4)
print base64.b64encode(s)
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment