-
Notifications
You must be signed in to change notification settings - Fork 271
Opal
Opal is the public transport smartcard ticketing system in Sydney, Australia. The official Android app can read these cards.
Opal cards are MIFARE DESFire EV1 cards, with the application ID 0x314553.
All files are restricted except for file 0x7, which is freely readable.
The file is 16 bytes long.
All multi-byte values are stored in little-endian. It may be easier to read this data after reversing the bytes.
Offsets and lengths listed are measured in bits. Ranges listed do not include the end bit.
| Start | End | Length | Field description |
|---|---|---|---|
| 0 | 32 | 32 | Serial number |
| 32 | 36 | 4 | Serial number check digit |
| 36 | 37 | 1 | Card status, 1 if blocked |
| 37 | 53 | 16 | Transaction sequence number |
| 53 | 74 | 21 | Balance in cents |
| 74 | 89 | 15 | Last tap date: days since epoch |
| 89 | 100 | 11 | Last tap date: minutes since 00:00 (localtime) |
| 100 | 103 | 3 | Mode of transport |
| 103 | 107 | 4 | Last tap usage type |
| 107 | 108 | 1 | Auto top-up enabled |
| 108 | 116 | 4 | Weekly paid journey count |
| 116 | 128 | 16 | CRC checksum |
All card numbers start with the OPAL_ISSUER_NUMBER constant "308522".
This is then concatenated with the serial number zero-padded to 9 digits,
followed by the check digit.
The epoch is 1 January 1980 (1980-01-01).
| ID | Description |
|---|---|
| 0 | Rail |
| 1 | Ferry |
| 2 | Bus |
| 3-7 | (reserved) |
| ID | Description |
|---|---|
| 0 | Card has not been used |
| 1 | Tap on: new journey |
| 2 | Tap on: intra-modal transfer |
| 3 | Tap on: inter-modal transfer |
| 4 | Tap on: new journey at Circular Quay (ferry) |
| 5 | Tap on: intra-modal ferry transfer at Circular Quay |
| 6 | Tap on: inter-modal ferry transfer at Circular Quay |
| 7 | Tap off: distance based fare |
| 8 | Tap off: flat-fare |
| 9 | Tap off: autocompleted journey(!?) |
| 10 | Tap off: end of trip without start(!?) |
| 11 | Tap on reversal |
| 12 | Unsuccessful tap (tap off) |
| 13 | (reserved) |
| 14 | (undefined) |
Intra-modal ferry transfers can only occur at Circular Quay.