Skip to main content

Cardtool

PyPI version codecov pre-commit Code style: black

A card data generation tool with DUKPT key derivation.

Installation


You should have python 3.9 or later to run this tool. So, please be sure you have the python interpreter installed before trying this setup guide.

Create a virtual environment:

python3 -m venv .env

Activate the virtual environment:

source .env/bin/activate

For testing purposes with alpha or beta versions, install this tool from TestPyPI:

pip3 install -U --extra-index-url https://test.pypi.org/simple/ cardtool==x.y.z[ab]N

Otherwise, install this tool from PyPI:

pip3 install cardtool

Finally, use it:

cardtool --help

Commands reference


Key decryption

A command to decrypt a TR-31 key block.

cardtool decrypt-key -kbpk <your_key_block_protection_key> -kcv <key_check_value> YOUR_KEY_BLOCK

Card data generation

A command to generate a file with encrypted card data using DUKPT key derivation.

cardtool gen-card -cfg <path_to_config_yaml> -fmt json|yaml path_to_dump_card_data.[json|yaml]

Card data generation configuration file


The following is a reference configuration file for the gen-card command.

!CardConfig
# current version of command
version: "0.1" 
# terminal information
terminal:
  !Terminal
  # terminal country
  country: MEX
# encryption keys
key:
  # keys used to encrypt data
  data:
    !Key
    # base derivation key
    bdk: 0123456789ABCDEFFEDCBA9876543210
    # key serial number
    ksn: FFFF4545450000100002
  # keys used to encrypt pin
  pin:
    !Key
    # base derivation key
    bdk: 0123456789ABCDEFFEDCBA9876543210
    # key serial number
    ksn: FFFF4545450000100002
# transaction information
transaction:
  !Transaction
  # type of transaction
  type: charge
  # transaction amount
  amount: 10.2
  # another transaction amount, e.g., cashback amount
  other_amount: 10.23
  # transaction currency
  currency: USD
  # date of transaction with DDMMYY format
  date: "220125"
# array of cards to generate
cards:
  - !Card
    # card label, useful as an identifier for this card
    label: "Test"
    # primary account number 16-19 digits
    pan: "5477820000001234"
    # card pin 4-6 digits
    pin: "1234"
    # card brand (Visa, Mastercard, Carnet)
    brand: "Mastercard"
    # cardholder name
    cardholder_name: Test 1
    # card expiry month
    expiry_month: "12"
    # card expiry year
    expiry_year: "24"
    # card service code
    service_code: "201"
    # card sequence number
    sequence_number: 1

Metadata

Release files for cardtool 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cardtool 0.0.6
File Size Uploaded
cardtool-0.0.6.tar.gz 32.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cardtool 0.0.6
File Interpreter ABI Platform
cardtool-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 53.8 kB

Release files / cardtool-0.0.6.tar.gz

Download URL cardtool-0.0.6.tar.gz
Size 32.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7a878ec7f3bda53c82703db36a1e0f30b9077aad326028ccfd6b618690b446d9
BLAKE2b-256 checksum
How to use checksums
0c0c2c709bc1bcb7b036264b6756bc075ab1ea60800e621335d371bea2c705c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / cardtool-0.0.6-py3-none-any.whl

Download URL cardtool-0.0.6-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96638494f4d3046de3fdd9815199d0c411a67c34a588c42c47b829c097b899fe
BLAKE2b-256 checksum
How to use checksums
85f6f227979088a4f185fc479f5283d80b0121ce60da738d7ba18158a9bf3471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page