Skip to content

CPF/CNPJ Handler is a library written in Java 8 that handles CPF and CNPJ validations

License

Notifications You must be signed in to change notification settings

LuisGuadagnin/cpf-cnpj-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPF/CNPJ Handler

"CPF/CNPJ Handler" is a library written in Java 8 that handles CPF and CNPJ validations.

CNPJ Definitions

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.

Check Digits

The check digits are generated by using the following algorithms.

First Digit

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.

Second Digit

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 Definitions

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.

Check Digits

The check digits are generated by using the following algorithms.

First Digit

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.

Second Digit

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.

About

CPF/CNPJ Handler is a library written in Java 8 that handles CPF and CNPJ validations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages