- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Encode and decode binhex4 files using Python (binhex)
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)
To convert hex in binary format
import binhex import sys infile = "test.hqx" binhex.binhex(infile, 'test.txt')
- Encode and decode uuencode files using Python
- Encode and decode XDR data using Python xdrlib
- Encode and decode MIME quoted-printable data using Python
- Encode and Decode Strings in C++
- Arduino – base64 encode and decode
- How to Encode and Decode JSON and Lua Programming?
- What is the difference between encode/decode in Python?
- Generate temporary files and directories using Python
- Decode Ways in Python
- Read and write WAV files using Python (wave)
- Read and write AIFF and AIFC files using Python (aifc)
- Rename multiple files using Python
- Read and write tar archive files using Python (tarfile)
- How to remove hidden files and folders using Python?