Command line tool to verify physical person registers status on Brazilian entities.
A pure C++ solution that links with the library CURL to manage HTTP requests.
The binary receives a CPF (Brazilian Physical Person Register) to be checked.
Then the CPF is validated on SERPRO (Brazilian Federal Data Processing Service) that uses a RESTful API.
The HTTP request implementation uses libCurl implementation (github.com/curl).
sudo apt install g++
This application was tested with g++ release 9.3.0
. To check the installed version of g++, run:
g++ --version
Also, the C++ version required to compile is std=c++11
or later.
sudo apt-get install libcurl-dev
This application was tested with the library libcurl4-openssl-dev
on release 7.68.0
g++ -o checkCpfCxx *.cxx -lcurl
./checkCpfCxx 123456789
Assuming that 123456789 is a CPF to be checked.
Attention: The -lcurl
flag is necessary to link with the installed Curl library.
Simply call the binary passing a CPF as parameter, the verdict will be printed on the command line.
CPF: 40442820135
SUCCESS: True
MESSAGE: Regular CPF (OK)
CPF: 11334739706
SUCCESS: False
MESSAGE: CPF not regular or not existant
./checkCpfCxx 40442820135
The application uses a service provided by SERPRO, so any test depends on this service being online.
The CPFs provided by SERPRO for testing are:
40442820135: Regular (Register OK)
63017285995: Regular (Register OK)
91708635203: Regular (Register OK)
58136053391: Regular (Register OK)
40532176871: Suspended (Problem with the registry)
47123586964: Suspended (Problem with the registry)
07691852312: Regularization Pending (Problem with the registry)
10975384600: Regularization Pending (Problem with the registry)
01648527949: Canceled by Multiplicity (Problem with the registry)
47893062592: Canceled by Multiplicity (Problem with the registry)
98302514705: Null (Problem with the registry)
18025346790: Null (Problem with the registry)
64913872591: Registration Canceled (Problem with the registry)
52389071686: Registration Canceled (Problem with the registry)
05137518743: Deceased Holder (Problem with the registry)
08849979878: Deceased Holder (Problem with the registry)
The application is composed by a set of source code files:
app.cxx : Main file, with main()
function.
middleware.hxx : C++ header file with definitions of functions and SERPRO structures.
middleware.cxx : C++ source file with the core implementation of the REQUEST to SERPRO service.
README.md : This file, explaining how the application works.
.gitignore : List of non-versioned files (such as the compiled binary).
After the compilation process, the non-versioned binary file checkCpfCxx
will be generated.
The application is configured with a personal TOKEN, please change it.
Its possible to generate a new TOKEN on SERPRO service page: servicos.serpro.gov.br.
The in use TOKEN is specified on the top of middleware.hxx
file.
If going to production the SERPRO service URL must also be changed (at the same file).
Heitor Peralles
[email protected]
linkedin.com/in/heitorperalles
github.com/heitorperalles/checkCpfCxx
MIT licensed. See the LICENSE file for details.