Repository navigation
Releases: ANASS99T/cardkit
Release list
ipmkit 0.1.2
ipmkit 0.1.1
First release on PyPI:
pip install ipmkitipmkit is lossless Mastercard IPM tooling and a drop-in replacement for cardutil 0.7.3, with its bugs fixed. IPM → CSV → IPM gives a file identical to the original, byte for byte.
ipmkit ipm2csv in.ipm -o out.csv
ipmkit csv2ipm out.csv -o rebuilt.ipm
ipmkit compare in.ipm rebuilt.ipmChanged since 0.1.0
Renamed from cardkit to ipmkit. The name cardkit isn't allowed on PyPI, so the package, imports and main command are now ipmkit. The GitHub repository keeps its name.
import cardkitbecomesimport ipmkit.- The
cardkitcommand becomesipmkit. - The
CARDKIT_CONFIGsetting becomesIPMKIT_CONFIG, and thecardkit.jsonconfig file becomesipmkit.json. - CSVs written by 0.1.0 can still be converted.
- Legacy command names such as
mci_ipm_to_csvare unchanged.
Packaging
- Author, project links and classifiers added.
- Published from GitHub Actions with PyPI Trusted Publishing, after tests on Python 3.9, 3.11 and 3.13.
- The
pinblockandkeymodules needpip install "ipmkit[crypto]".
See the 0.1.0 release for the full feature list, and the README for usage.
cardkit 0.1.0
First release of cardkit: lossless Mastercard IPM tooling and a drop-in replacement for cardutil 0.7.3, with its bugs fixed.
Highlights
IPM → CSV → IPM gives a file identical to the original, byte for byte.
- Values are written exactly as they are in the file: spaces, leading zeros and dates are left alone.
- DE55 is written as hex, and the PDS data in DE48/DE62/DE123–125 exactly as in the file.
- Records that can't be parsed are kept whole as hex, so nothing is ever lost.
- File details (encoding, 1014 blocking, block trailers, end-of-file record, trailing bytes) are kept in a
METArow. ipm2csvchecks that the CSV rebuilds the identical file before it finishes.
File header and trailer generation. When a CSV has no 1644/697 header or 1644/695 trailer, csv2ipm generates them:
- File ID (PDS 0105), copied from the existing header/trailer if there is one.
- Processing mode (PDS 0122).
- File amount checksum (PDS 0301) and message count (PDS 0306).
Every IPM message type: presentments (1240), chargebacks (1442), fees (1740), addenda and the other 1644 file messages.
Fast: large files are converted on several CPU cores (--workers), and records always stay in file order. On 100,002 records (72 MB):
| cardutil 0.7.3 | cardkit 0.1.0 | |
|---|---|---|
| IPM → CSV | 38.3 s | 1.8 s, verification included |
| CSV → IPM | 10.8 s | 0.85 s |
| Rebuilt file | 27 MB, different | 72 MB, identical |
Other defaults and detection
- Encoding is EBCDIC cp037 unless
--encodingis given. - 1014 blocking is detected whatever bytes end the blocks (
x'4040'orx'0000').
Usage
pip install https://github.com/ANASS99T/cardkit/releases/download/v0.1.0/cardkit-0.1.0-py3-none-any.whl
cardkit ipm2csv in.ipm -o out.csv
cardkit csv2ipm out.csv -o rebuilt.ipm
cardkit compare in.ipm rebuilt.ipmcardutil fixes
The cardkit.iso8583, mciipm, card, pinblock, key and config modules keep cardutil's API. Change cardutil to cardkit in your imports.
- Messages with only a primary bitmap can be read, and DE128 is processed.
- A value too long for its field raises an error. Before, it was cut off, or it corrupted the length prefix.
dumps()no longer changes the dict passed to it, and too much PDS data gives a clear error.- DE55 is parsed as real BER-TLV, including multi-byte tags and long-form lengths.
- 10–12 digit PINs work in ISO-0 and ISO-4 PIN blocks.
- Luhn validation works under
python -O, and short card numbers are masked safely. loadsis about 2.7× faster.
See ANALYSIS.md for the full list.