cardnumFinancial

Mock Jutsu HOW-TO | EN

The cardnum function within the mock-jutsu library is a specialized tool designed to generate realistic credit card numbers for software testing and development environments. High-quality mock data is essential for developers building financial applications, e-commerce platforms, or payment gateways where data integrity is paramount. By using mock-jutsu, teams can produce valid-looking card numbers without compromising security or relying on sensitive production information, ensuring a safe and efficient development process.

What sets the cardnum function apart is its strict adherence to the Luhn algorithm, also known as the "modulus 10" algorithm. This checksum formula is the global industry standard used to validate a variety of identification numbers, particularly credit card numbers. When you invoke the cardnum generator, the library ensures that every string produced passes this validation check, mimicking the structure of real-world cards from major providers. This level of accuracy is critical for testing input validation logic and ensuring that front-end forms or back-end processing services correctly identify valid card formats before they reach the payment processor.

In practical testing scenarios, the cardnum function proves invaluable for stress-testing database schemas and verifying payment processing workflows. Developers can use this test data to simulate high-volume transactions or to populate staging environments with diverse datasets that reflect real-world usage. Whether you are using the Python API with jutsu.generate('cardnum'), the command-line interface for quick scripting, or integrating it directly into performance tests via JMeter, the tool offers seamless flexibility. This versatility ensures that QA engineers and developers can maintain a consistent flow of reliable mock data across the entire software development lifecycle.

Integrating mock-jutsu into your CI/CD pipeline significantly reduces the friction associated with manual data creation. By automating the generation of test data that follows strict financial standards, the cardnum function helps prevent bugs that often arise from poorly formatted input. Ultimately, leveraging mock-jutsu for financial data generation empowers teams to build more robust, secure, and reliable applications, ensuring that every payment-related component is thoroughly vetted and functional before reaching a production environment.

CLI Usage
mockjutsu generate cardnum --network visamockjutsu bulk cardnum --count 10mockjutsu export cardnum --count 10 --format jsonmockjutsu export cardnum --count 10 --format csvmockjutsu export cardnum --count 10 --format sql# --mask: regulation-compliant output (PCI DSS / GDPR / KVKK)mockjutsu generate cardnum --maskmockjutsu bulk cardnum --count 5 --mask
Python API
from mockjutsu import jutsujutsu.generate('cardnum')jutsu.bulk('cardnum', count=10)jutsu.template(['cardnum'], count=5)# with --network parameterjutsu.generate('cardnum', network='visa')# mask=True: regulation-compliant outputjutsu.generate('cardnum', mask=True)jutsu.bulk('cardnum', count=5, mask=True)
JMeter
${__mockjutsu_financial(cardnum)}${__mockjutsu_financial(cardnum:visa)}# JMeter Function: __mockjutsu_financial# Parameter 1: cardnum OR cardnum:# Qualifier values: visa|mc|amex|troy|mir|jcb|discover|unionpay|maestro# Parameter 2: (not required for this function)# Add 'mask' keyword to get a regulation-compliant masked value${__mockjutsu_financial(cardnum,mask)}
REST API
GET /generate/cardnum# → {"type":"cardnum","result":"...","status":"ok"}GET /bulk/cardnum?count=10POST /template {"types":["cardnum"],"count":1}# mask=true: regulation-compliant outputGET /generate/cardnum?mask=trueGET /bulk/cardnum?count=5&mask=true

Parameters

Parameter Values Description
--network visa|mc|amex|troy|mir|jcb|discover|unionpay|maestro Card network
--mask true | false Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…)

Other Languages