Skip to main content Skip to complementary content

Credit card generation functions

You can generate credit card numbers.

To mask credit card numbers by using the Format-Preserving Encryption, use the Credit Card masking functions.

Function Random generation Consistent generation Bijective generation Input data validation
Generate credit card Yes No No No
Generate credit card and keep original bank Yes No No No

Generate credit card

This function generates a valid credit card number.

This function requires no extra parameter.

This function applies on String or Long values.

Three types of credit card that can be generated:
  • Visa
  • MasterCard
  • American Express
One type is randomly chosen and a credit card number is randomly generated. Then, the generated credit card number passes algorithms that detect false credit card numbers.

In the following example, the masked value is a valid Visa credit card number, regardless of the input value.

Input value Example of a masked value
A26 4346065537027896

Generate credit card and keep original bank

When the input value is a correct Visa, a MasterCard, or an American Express credit card number, this function generates a credit card number from the same company and keeps the prefix

This function applies on String or Long values.

This function requires no extra parameter.

The generated credit card number passes algorithms that detect false credit card numbers.

In the following example, the input value is a valid American Express credit card number. The masked value is also a valid American Express credit card number.

Input value Example of a masked value
346992550391727 348482709815527

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!