The binhex module encodes and decodes files in binhex4 format. This format is used in the representation of Macintosh files in ASCII. Only the data fork is handled.
The binhex module defines the following functions −
binhex.binhex(input, output): Convert a binary file with filename input to binhex file output. The output parameter can either be a filename or a file-like object (any object supporting a write() and close() method).
binhex.hexbin(input, output): Decode a binhex file input. input may be a filename or a file-like object supporting read() and close() methods. The resulting file is written to a file named output unless the argument is None in which case the output filename is read from the binhex file.
import binhex import sys infile = "file.txt" binhex.binhex(infile, 'test.hqx')
(This file must be converted with BinHex 4.0)
:#'CTE'8ZG(Kd!&4&@&3rN!3!N!8G!*!%Ql&6D@e`E'8JDA-JBQ9dG'9b)(4SB@i JBfpYF'aPH-bk!!!:
To convert hex in binary format
import binhex import sys infile = "test.hqx" binhex.binhex(infile, 'test.txt')