Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- from itertools import izip_longest
- import string
- from binascii import hexlify
- # global variables
- # end global variables
- def convert():
- pass
- def unconvert():
- pass
- fd = open("bin", "wb")
- def grouper(n, iterable, fillvalue=None):
- "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
- args = [iter(iterable)] * n
- return izip_longest(fillvalue=fillvalue, *args)
- def convert2bin(intStr):
- return '{0:x}'.format( intStr )
- num = 3405848999
- print convert2bin(num).zfill(8)
- for i in grouper(2, convert2bin(num).zfill(8), 0):
- i = string.join(i, "")
- print i
- fd.write(chr(int(i, 16)))
- fd.close()
- fd = open("bin", "rb")
- read = fd.read()
- print read
- print int(hexlify(read), 16)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement