WordPerfect for the Macintosh from version 2 onwards starts with a 16-byte header whose
bytes 1 to 3 are WPC; version 1.x has no header. Corel’s own format
documentation is not freely published; this page follows libwpd, the open-source
WordPerfect reader used by LibreOffice, and says where something is not known.
The WPC header
The table follows the header as libwpd reads it for Macintosh files. It gives the numbers in the order and size libwpd uses; no source states the byte order of the header’s own fields in Macintosh files (the streams after it are big-endian, see the function codes), so that is unknown.
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 1 | – | 0xFF. |
1 | 3 | Signature | WPC (57 50 43). A reader checks these three bytes. |
4 | 4 | Document pointer | Offset of the start of the document area (the text and codes), after the resource fork. |
8 | 1 | Product type | The program family that wrote the file: 1 for WordPerfect. |
9 | 1 | File type | 0x2C WordPerfect for the Macintosh document. Other values are other WordPerfect Corporation files (templates, macros, dictionaries and so on), which libwpd does not read. |
10 | 1 | Major version | See versions. |
11 | 1 | Minor version | The versions table below does not use it. |
12 | 2 | Encryption | 0 when the file is not encrypted; otherwise a checksum of the password (see encryption). |
16 | … | Resource fork | An embedded Macintosh resource fork, up to the document pointer: at offset 16 come its data offset, map offset, data length and map length (32-bit each). libwpd reads the pictures of graphics boxes from it (resources PICT and WBOX). Some 2.x files have no resource fork (document pointer 16 or less). |
The source read for this site gives no meaning for offsets 14 and 15 in Macintosh files (in the DOS and Windows files they are reserved or an index offset), so they are unknown here.
Versions
| File type | Major | Format |
|---|---|---|
0x2C | 2 | WordPerfect 2.x for the Macintosh. |
0x2C | 3 | WordPerfect 3.0 to 3.5 for the Macintosh. |
0x2C | 4 | WordPerfect 3.5e for the Macintosh. |
The three are described together on the function codes page.
Version 1.x: no header
WordPerfect 1.x for the Macintosh has no WPC header: the file is the document stream from its first byte. Programs recognise it by checking that the bytes are text and well-formed function codes (version 1.x). A 1.x file is encrypted from offset 6.
Encryption
WordPerfect for the Macintosh protects a document by scrambling its bytes with the password; this is not secure and is easily reversed. No description of WordPerfect’s encryption was ever made available by WordPerfect or its later owners (WordPerfect for DOS Updated); libwpd’s method was worked out independently. It handles 1.x and 2.x to 3.5e files as follows:
- The password is turned to upper case (letters a to z only).
- The checksum is built over the password’s characters: start at 0; for each character, rotate the 16-bit value right by one bit and XOR it with the character shifted left eight bits. A file is protected when its stored checksum is not 0, and the password is right when the checksums match.
- Bytes before the start offset are not encrypted: 6 for 1.x files, and the document pointer for 2.x to 3.5e files (the resource data is scrambled separately).
- The byte at position
iafter the start is XORed with the password characteri mod lengthand with the mask(length + 1 + i) mod 256.
libwpd reports any encrypted file with major version 2 as using an unsupported encryption, which also catches Macintosh 2.x files that its parser could otherwise unscramble.