Alipay+ DocsAlipay+ Docs

Data encoding specification

Alipay+ NFC SDK supports ASCII and BCD encoding modes. If you provide custom data, you must pass it as a 20-character hexadecimal string representing 10 bytes of raw data. The SDK then encodes this data based on the selected encoding mode.

Specifications

ASCII mode

BCD mode

Supported characters

0-9, A-Z, a-z, @, #

0-9

Input capacity

Up to 10 characters.

Up to 20 digits and then packed into 10 bytes.

Encoding logic

Each character is converted directly to its 1-byte ASCII value.

Every two digits are compressed into a single byte.

Sample custom data

copy
// ASCII Mode example: Encode "123abc" as ASCII bytes
byte[] asciiData = "123abc".getBytes(StandardCharsets.US_ASCII);
// Result: {0x31, 0x32, 0x33, 0x61, 0x62, 0x63}

// BCD Mode example: Encode "12345678901234567890" as packed BCD
byte[] bcdData = new byte[]{0x12, 0x34, 0x56, 0x78, (byte)0x90,
                            0x12, 0x34, 0x56, 0x78, (byte)0x90};