Advertisement
Peaser

ascii_binary

Jul 2nd, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import binascii
  2.  
  3. def binencode(data):
  4.     try:
  5.         return bin(int(binascii.hexlify(data), 16)).replace('b','')
  6.     except:
  7.         return None
  8.         print "Error"
  9. def bindecode(data):
  10.     try:
  11.         n = int(data, 2)
  12.         return binascii.unhexlify('%x' % n)
  13.     except:
  14.         return None
  15.         print "Error"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement