Ambimat GroupAmbimatAmbiSecureeSIM InitiativeEngineering BlogAhmedabad · India · Est. 1981
Encoding utility

Length-Field Encoder

Convert an integer length into the binary length field used by various protocols: BER long-form (X.690), GP DGI long-form, plain u8, and u16 in big-endian and little-endian. The right format the first time saves a lot of debugging.

Client-sideBER / DGI / u8 / u16

Input

Result

Type something to convert.
All encoding runs locally.

BER vs DGI vs raw

BER (X.690) length: short form when ≤ 127; long form is 0x80|N followed by N length bytes. DGI (GlobalPlatform Data Group Identifier) length: short when < 0xFF; long form is 0xFF followed by 2 length bytes. Raw u8/u16 just write the value at the chosen width.

Spec

X.690 (BER lengths) and GP Card Specification 2.3.1 (DGI).

Companion tool

TLV parsing of what you just wrote.

TLV parser →

Companion tool

Need BE/LE for raw fields?

Endian converter →