Skip to main content

An encrypted card generator tool

Project description

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

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

cardtool-0.0.6.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

cardtool-0.0.6-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file cardtool-0.0.6.tar.gz.

File metadata

  • Download URL: cardtool-0.0.6.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for cardtool-0.0.6.tar.gz
Algorithm Hash digest
SHA256 7a878ec7f3bda53c82703db36a1e0f30b9077aad326028ccfd6b618690b446d9
MD5 5007fd4316f162e7431586c6386da6ac
BLAKE2b-256 0c0c2c709bc1bcb7b036264b6756bc075ab1ea60800e621335d371bea2c705c8

See more details on using hashes here.

File details

Details for the file cardtool-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: cardtool-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for cardtool-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 96638494f4d3046de3fdd9815199d0c411a67c34a588c42c47b829c097b899fe
MD5 c2ab8f521a14b740009dc3829d10a603
BLAKE2b-256 85f6f227979088a4f185fc479f5283d80b0121ce60da738d7ba18158a9bf3471

See more details on using hashes here.

Supported by

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