BR - Financial ID (Algorithm frameworks)
The BR - Financial ID framework masks string input of formatted CPF and CNPJ numbers from Brazil. It can mask the forms with or without punctuation. The earlier digits are masked with a chained instance of CM Numeric, and a checksum is calculated from them for the last two. The input and and output numbers are both validated for length, format and accuracy of the checksum. The format of CPF has 9 randomized digits with a total of 1 billion combinations, making masked collisions possible by its nature but very unlikely.
This framework was created based on a plugin developed by professional services. It’s default instance replicates the behavior distributed to clients in the field. At this time there is no UI for framework, though additional instances can be created through the API with two configurable options:
maskInvalidInput - This is configurable to true or false. If false, it will throw a NonConformantDataException for string inputs that do not pass validation as CPF or CNPJ numbers.
fallbackAlgorithm - This is a configurable algorithm reference. If maskInvalidInput is true, then string input that does not pass validation will be sent the this algorithm. The chained algorithm may throw it’s own NonConformantDataExceptions.
Creating a payment algorithm via API
Here is an example post to create an instance of BR - Financial ID with a fallback algorithm enabled:
{
"algorithmName": "BR Financial ID - Custom Fallback",
"algorithmType": "COMPONENT",
"description": "Masks CPF and CNPJ Brazilian registry numbers and falls back to a custom algorithm.",
"maskType": "STRING",
"frameworkId": 33,
"pluginId": 7,
"algorithmExtension": {
"maskInvalidInput": true,
"fallbackAlgorithm": {
"name": "dlpx-core:CM Alpha-Numeric"
}
}
}
The algorithm name can be changed to any valid algorithm in the chosen masking engine. The appropriate framework ID and plugin ID should be taken from the chosen masking engine.
Examples
Valid CPF and CNPJ before and after masking:
"842.262.714-08" → "209.674.029-05"
"70.193.999/0001-18" → "28.823.097/0001-51"
"84226271408" → "20967402905"
"70193999000118" → "28823097000151"
Invalid inputs masked with a CM Alpha-Numeric fallback:
"83.tomato.590/0001-50" → "84.byhmsk.760/8830-11"
"11111111111111" → "76005296937223"
"2" → "1"
The above invalid examples will not be masked and will throw a NonConformantDataException visible in the job logs if maskInvalidInput is false.