Skip to content
David edited this page Jul 5, 2015 · 23 revisions

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.

File 0x7 Format

The file is 16 bytes long.

All multi-byte values are stored in little-endian, unless specified otherwise. For convenience, it is recommended to reverse the bytes in the file.

Offsets and lengths listed are measured in bits. Ranges listed do not include the end bit.

Forward:

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 (two's complement)
74 89 15 Last tap date: days since epoch
89 100 11 Last tap time: minutes since 00:00
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 CRC16 checksum (big-endian!)

Reverse:

Start End Length Field description
0 16 16 CRC16 checksum (bytes reversed)
16 20 4 Weekly paid journey count
20 21 1 Auto top-up enabled
21 25 4 Last tap usage type
25 28 3 Mode of transport
28 39 11 Last tap time: minutes since 00:00
39 54 15 Last tap date: days since epoch
54 75 21 Balance in cents (two's complement)
75 91 16 Transaction sequence number
91 92 1 Card status, 1 if blocked
92 96 4 Serial number check digit
96 128 32 Serial number

Card number

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.

Tap date/time

The epoch is 1 January 1980 (1980-01-01).

It is believed that tap dates and times are stored in local time (Australia/NSW).

Modes of transport

ID Description
0 Rail
1 Ferry
2 Bus
3-7 (reserved)

Usage types

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 (reserved)

Intra-modal ferry transfers can only occur at Circular Quay.

Clone this wiki locally