iso8583 - a Python package for parsing ISO8583 data
iso8583 package serializes and deserializes ISO8583 data between raw bytes ISO8583 data and a regular Python dict.
iso8583 package supports custom specifications that can define:
Field length and data encoding, such as BCD, ASCII, EBCDIC, etc.
Field length count measured in bytes or nibbles.
Field type, such as fixed, LLVAR, LLLVAR, etc.
Maximum length
Optional field description
Multiple specifications can co-exist to support ISO8583 messages for POS, ATM, file actions, and so on. Simply define a new specification dictionary. iso8583 package includes a starter specification in iso8583.specs module that can be used as a base to create own custom/proprietary specifications.
Additional information is available on Read The Docs.
Installation
iso8583 is published on PyPI as pyiso8583 and can be installed from there:
pip install pyiso8583
Encoding & Decoding
Use iso8583.decode to decode raw ISO8583 message. It returns two dictionaries: one with decoded data and one with encoded data.
>>> import pprint
>>> import iso8583
>>> from iso8583.specs import default_ascii as spec
>>> encoded_raw = b'02004000000000000000101234567890'
>>> decoded, encoded = iso8583.decode(encoded_raw, spec)
>>> pprint.pp(decoded)
{'t': '0200', 'p': '4000000000000000', '2': '1234567890'}
>>> pprint.pp(encoded)
{'t': {'len': b'', 'data': b'0200'},
'p': {'len': b'', 'data': b'4000000000000000'},
'2': {'len': b'10', 'data': b'1234567890'}}
Modify the decoded message to send a response back. Change message type from ‘0200’ to ‘0210’. Remove field 2 (PAN). And add field 39 (Response Code).
>>> decoded['t'] = '0210'
>>> decoded.pop('2', None)
'1234567890'
>>> decoded['39'] = '05'
Use iso8583.encode to encode updated ISO8583 message. It returns a raw ISO8583 message and a dictionary with encoded data.
>>> encoded_raw, encoded = iso8583.encode(decoded, spec)
>>> encoded_raw
bytearray(b'0210000000000200000005')
>>> pprint.pp(decoded)
{'t': '0210', 'p': '0000000002000000', '39': '05'}
>>> pprint.pp(encoded)
{'t': {'len': b'', 'data': b'0210'},
'p': {'len': b'', 'data': b'0000000002000000'},
'39': {'len': b'', 'data': b'05'}}
Pretty Print Messages
Use iso8583.pp to pretty print ISO8583 message.
>>> import iso8583
>>> from iso8583.specs import default_ascii as spec
>>> encoded_raw = b'02004000000000000000101234567890'
>>> decoded, encoded = iso8583.decode(encoded_raw, spec)
>>> iso8583.pp(decoded, spec)
t Message Type : '0200'
p Bitmap, Primary : '4000000000000000'
2 Primary Account Number (PAN) : '1234567890'
>>> iso8583.pp(encoded, spec)
t Message Type : b'0200'
p Bitmap, Primary : b'4000000000000000'
2 Primary Account Number (PAN) : b'10' b'1234567890'
Contribute
iso8583 package is hosted on GitHub.
Feel free to fork and send contributions over.
Metadata
Release files for pyiso8583 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyiso8583-4.0.1.tar.gz | 33.7 kB | Without provenance | Details for pyiso8583-4.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyiso8583-4.0.1-py3-none-any.whl | Python 3 | none | any | Details for pyiso8583-4.0.1-py3-none-any.whl |
Total release size: 53.6 kB
Release files / pyiso8583-4.0.1.tar.gz
| Download URL | pyiso8583-4.0.1.tar.gz |
|---|---|
| Size | 33.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ed8c56920ba79e23e78978e54b0320403445a72ac9fc97aa877cf0afe6fd824
|
|
BLAKE2b-256 checksum How to use checksums |
2172db79a8f78d3595f949d55bdf567cc11bce269334b52d569d7381d203f21b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / pyiso8583-4.0.1-py3-none-any.whl
| Download URL | pyiso8583-4.0.1-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a30ba63d2ccb61f0d9464add6ed2442b72687b8193743cfdfeace8ebaf6f6ce7
|
|
BLAKE2b-256 checksum How to use checksums |
54dce1b0dbf4a57da8a375ea5974878735ed13e0cb38978fa699b61a0f5185d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for pyiso8583 4.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.