"CPF/CNPJ Handler" is a library written in Java 8 that handles CPF and CNPJ validations.
CNPJ (short for Cadastro Nacional da Pessoa Jurídica in Portuguese, or National Registry of Legal Entities) is an identification number issued to Brazilian companies by the Department of Federal Revenue of Brazil (in Portuguese, Secretaria da Receita Federal). The CNPJ consists of a 14-digit number formatted as 00.000.000/0001-00 — The first eight digits identify the company, the four digits after the slash identify the branch or subsidiary ("0001" defaults to the headquarters), and the last two are check digits.
The check digits are generated by using the following algorithms.
A weighted sum is performed by using the first 12 digits and these weights, respectively: [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]. Then a sum mod 11 operation is performed. The result is the first check digit. If it is greater than 9, it becomes 0.
A weighted sum is performed by using the first 12 digits + the first check digit and these weights, respectively: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]. Then a sum mod 11 operation is performed. The result is the second check digit. If it is greater than 9, it becomes 0.
CPF (short for Cadastro de Pessoa Física in Portuguese, or Natural Persons Register") is an identification number issued to Brazilian individual taxpayers by the Department of Federal Revenue of Brazil (in Portuguese, Secretaria da Receita Federal). The CPF consists of a 11-digit number formatted as 000.000.000-00 — The first eight digits identify the person, the ninth digit identify the region where the CPF was issued, and the last two are check digits.
The check digits are generated by using the following algorithms.
A weighted sum is performed by using the first 9 digits and these weights, respectively: [10, 9, 8, 7, 6, 5, 4, 3, 2]. Then a sum mod 11 operation is performed. The result is the first check digit. If it is greater than 9, it becomes 0.
A weighted sum is performed by using the first 9 digits + the first check digit and these weights, respectively: [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]. Then a sum mod 11 operation is performed. The result is the second check digit. If it is greater than 9, it becomes 0.