Format:DWG
| Vendor | Autodesk |
|---|---|
| Magic | "AC10xx" (6 ASCII bytes at offset 0) |
| Extensions | .dwg |
| On this wiki | Facts · Code · Notes · Topics |
AutoCAD drawing file (.dwg): starts with a 6-byte ASCII version string AC1009 ... AC1032 that names the release family; R2004 and later put an XOR-encrypted file header at 0x80. Read from LibreDWG.
Identification
A DWG file begins with a 6-byte ASCII version string at offset 0, of the form AC10xx for R11 and later. LibreDWG keeps a table of these (src/common.c lines 36-93): the header string, a human description and its internal dwg_version number. The strings it lists as seen in real files:
| Header | AutoCAD release (LibreDWG description) |
|---|---|
| AC1009 | Release 11/12 (LT R1/R2) |
| AC1012 | Release 13 |
| AC1014 | Release 14 |
| AC1015 | Release 2000 (also listed for 2000i and 2002 as AC1016, AC1017) |
| AC1018 | Release 2004 |
| AC1021 | Release 2007 |
| AC1024 | Release 2010 |
| AC1027 | Release 2013 |
| AC1032 | Release 2018 |
Older files use other strings: MC0.0 (MicroCAD 1.1), AC1.2, AC1.3, AC1.40, AC1.50, AC2.10, AC2.21, AC2.22, and AC1001 to AC1008 for R2.4 to the R11 betas. LibreDWG also lists AC1010/AC1011 as pre-R13 builds, AC1013 as R13c3, and the AC1016, AC1017 strings for 2000i and 2002. Several releases share one string: LibreDWG's table has commented-out entries marked "not seen" for AC1019 and AC1020 (2005, 2006), AC1022 and AC1023 (2008, 2009), AC1025 and AC1026 (2011, 2012), AC1028 to AC1031 (2014 to 2017) and AC1033 to AC1035 (2019 to 2021), so files from those releases were not observed under their own strings; the table maps the 2004, 2007, 2010, 2013 and 2018 strings to the release that introduced them (lines 71-92). Unverified: that the other releases write the previous string. The same table has a last entry AC103-4 for an AutoCAD 2022 beta, and r>2022 with no string for later releases.
The DXF text format uses the same strings in its $ACADVER header variable, see Format:DXF.
R2004 and later: encrypted header
From AC1018 on, LibreDWG reads a file header at offset 0x80 that is obscured by a symmetric XOR with a keystream generated on the fly (src/decode.c, decrypt_R2004_header, lines 3467-3480): a 32-bit seed starts at 1, and for every byte seed = seed * 0x343fd + 0x269ec3 and the byte is XORed with seed >> 16. The same function encrypts and decrypts. After decryption the header must begin with the file ID string AcFssFcAJMB (LibreDWG compares the first 8 bytes only, line 3526), and a CRC32 over the first 0x6c bytes (with the CRC field zeroed) is checked (lines 3536-3542). The page and section maps that follow are not described here.
Tools and sources
- LibreDWG (GPL-3.0), reads and writes many DWG versions: https://github.com/LibreDWG/libredwg
- ezdxf (MIT) handles DXF, not DWG.
Unverified: the bytes between offset 6 and 0x80 (maintenance release byte, preview image pointer, code page) differ by version; read src/decode.c in LibreDWG for each.
Code & repositories
- https://github.com/LibreDWG/libredwg @
f860b0fb76d5f8effb5a70769a3389cb1e0308c8· license: GPL-3.0-or-later (declared by the contributor for the files used; GitHub reports GPL-3.0 for the repository)
GNU LibreDWG, DWG reader/writer; src/common.c version table and src/decode.c R2004 header
Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-13; Note: the latest release ships binaries; the wiki links only the source, never the binaries