The Payment Card framework masks payment card numbers based on the starting digits to be preserved and the minimum number of positions to be masked. This framework is built on top of the Character Mapping Algorithm Framework with a character set of [0-9]. All characters outside of this character group remain unmasked. Masked values are calculated algorithmically using the algorithm's key, so rekeying the algorithm will cause different outputs to be generated for each input. The last digit may remain the same if the calculated check digit is equivalent to the last digit of the input. Any inputs with more than one digit will never mask to the original value.
Any inputs with a single digit will remain unmasked.
This framework preserves the validity of the payment card number using the Luhn check. All input values with valid Luhn checks will be masked to values with valid Luhn checks. All invalid values with invalid Luhn checks will be masked to values with invalid Luhn checks.
As an example, a Payment Card algorithm with a minMaskedPositions value of 6 and a preserve value of 6 may mask as follows:
"5419033646326699" → "5419036803270758"
"5419-0336-4632-6699" → "5419-0368-0327-0758"
"5319abc0339def4632ghi6599!" → "5319abc0364def1507ghi4137!"
All inputs with the same sequence of digits masked with the same algorithm configuration will result in the same output values.