Skip to main content

A serializer and deserializer of ISO8583 data.

Project description

iso8583

PyPI Documentation Status Test coverage

iso8583 module serializes and deserializes ISO8583 data between a bytes or bytearray instance containing ISO8583 data and a Python dict.

iso8583 supports custom specifications that can define field encoding (e.g. ASCII, EBCDIC, ISO8859-1, BCD, etc.), field types (e.g. fixed, LLVAR, LLLVAR, etc.), and maximum length

Install:

pip install pyiso8583

Decode iso8583 data received from a socket.

>>> import iso8583
>>> from iso8583.specs import default
>>> s = b'0200\x40\x10\x00\x00\x00\x00\x00\x00161234567890123456123456'
>>> doc_dec, doc_enc = iso8583.decode(s, spec=default)

Contents of the produced dictionaries.

>>> import pprint
>>> pprint.pp(doc_dec) # Decoded data
{'bm': {2, 12},
 't': '0200',
 'p': '4010000000000000',
 '2': '1234567890123456',
 '12': '123456'}
>>> pprint.pp(doc_enc) # Encoded data
{'bm': {2, 12},
 't': {'len': b'', 'data': b'0200'},
 'p': {'len': b'', 'data': b'@\x10\x00\x00\x00\x00\x00\x00'},
 '2': {'len': b'16', 'data': b'1234567890123456'},
 '12': {'len': b'', 'data': b'123456'}}

Pretty print result using iso8583.pp.

>>> iso8583.pp(doc_dec, spec=default) # Decoded data only
'bm'  Enabled Fields                      : [2, 12]
't'   Message Type                        : [0200]
'p'   Bitmap, Primary                     : [4010000000000000]
'2'   Primary Account Number (PAN)        : 16 [1234567890123456]
'12'  Time, Local Transaction             : [123456]

Add or remove fields.

>>> iso8583.del_field(doc_dec, '12') # Decoded data only
'123456'
>>> doc_dec['t'] = '0210'
>>> iso8583.add_field(doc_dec, '39', '00')  # Decoded data only

Encode iso8583 data to send to a socket.

>>> s, doc_enc = iso8583.encode(doc_dec, spec=default)
>>> print(s)
bytearray(b'0210@\x00\x00\x00\x02\x00\x00\x0016123456789012345600')

For more info read the docs.

Contribute

iso8583 is hosted on GitHub.

Feel free to fork and send contributions over.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyiso8583-1.0.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

pyiso8583-1.0.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pyiso8583-1.0.1.tar.gz.

File metadata

  • Download URL: pyiso8583-1.0.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

File hashes

Hashes for pyiso8583-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2fdd2edbb796350c11c133099fd88947bca93b11ad3249d7f90a46d276fdeb23
MD5 f7a5e949fd1b9abdb0fb9b0d722292b0
BLAKE2b-256 999e342a36e0334f398cb6beb8f92b42f10406a476799699b3e9eaab6371a409

See more details on using hashes here.

File details

Details for the file pyiso8583-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyiso8583-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.8.0

File hashes

Hashes for pyiso8583-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c2c6568a36d183bb3f845f2b4dbabdc93ce9787f2aecddfc7aa94bed8d7a79c
MD5 778d4aa45aecf41b21f5c6be1757f2ff
BLAKE2b-256 3228ad64c7210c1c1d1fa2d0d8c1e5254bc3f017b88d24138cded8de2b51fa3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page