Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Nishtha Thakur

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')

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.