Search code examples
iso8583

what is the packed binary data and unpacked binary data in ISO 8583 message?


I am new in this field, and working on payment gateway, please tell me what is the difference between packed and unpacked binary data used in iso8583 message...!


Solution

  • The schema definition files for ISO8583 are available at http://dfdlschemas.github.io/ISO8583. In ISO8583_1993.xsd it says:

    * This DFDL schema provides a DFDL model for ISO8583 1993 binary data 
    * where each bitmap in the message is encoded as 8 bytes of binary data
    * (8 bits per byte). The bitmaps are said to be 'packed'.
    

    So, the term "packed" refers to the bitmaps, which can be either packed or unpacked.

    In en.wikipedia.org/wiki/ISO_8583#Bitmaps, it says

    The bitmap may be transmitted as 8 bytes of binary data, or as 16 hexadecimal > characters 0-9, A-F in the ASCII or EBCDIC character sets.

    In data structures, packed binary data usually means that more (if not all available) bit combinations are used to encode some values, while unpacked means that some bit combinations remain unused, either to improve readability or to make certain calculations easier (but unpacked data takes more space).

    For example, one unsigned byte (8 bits) can encode numbers from 0 to 255. If the numbers are BCD encoded, only numbers from 0 to 99 can be represented, and some bit combinations remain unused. However, it is in some cases easier to base calculations on a BCD encoded number than on a binary encoded number.

    In summary, ISO 8583 defines two different encodings:

    • packed which is 8 bytes of binary data
    • unpacked which is 16 bytes as hexadecimal characters (in two different encodings, but that is another aspect).

    One obvious difference is, that when you dump this data to a console, you can immediately read the unpacked data as hexadecimal numbers, while the binary encoding will only print some garbage characters, depending on your console, your locale and the font which you have installed.