Skip to content

Command line tool written in C++ using libCurl to verify CPF status on Brazilian entities.

License

Notifications You must be signed in to change notification settings

heitorperalles/checkCpfCxx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

checkCpfCxx

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).

Quick Start (on Linux)

Install GNU g++ compiler

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.

Install lib Curl for Development

sudo apt-get install libcurl-dev

This application was tested with the library libcurl4-openssl-dev on release 7.68.0

Build and run checkCpfCxx (from the project root folder)

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.

Usage

Simply call the binary passing a CPF as parameter, the verdict will be printed on the command line.

Success example

CPF:      40442820135
SUCCESS:  True
MESSAGE:  Regular CPF (OK)

Error example

CPF:      11334739706
SUCCESS:  False
MESSAGE:  CPF not regular or not existant

Testing the Binary

Testing manually

Call the binary passing a test CPF as parameter:

./checkCpfCxx 40442820135

List of testing CPFs provided by SERPRO:

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)

Implementation

File structure

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.

API Credentials

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).

Application Info

Author

Heitor Peralles
[email protected]
linkedin.com/in/heitorperalles

Source

github.com/heitorperalles/checkCpfCxx

License

MIT licensed. See the LICENSE file for details.

About

Command line tool written in C++ using libCurl to verify CPF status on Brazilian entities.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages