Skip to content

Instantly share code, notes, and snippets.

@debedb

debedb/m2c.py

Created Aug 25, 2015
Embed
What would you like to do?
mod_uid hex to cookie
import base64
import struct
import sys
def main():
"""
http://www.lexa.ru/programs/mod-uid-eng.html
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__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.