
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Python module for brazilian register numbers for persons (CPF) and companies (CNPJ) and mask generator to string or int CPF/CNPJ.
Python module for brazilian register numbers for persons (CPF) and companies (CNPJ). If want this validation in your web application, please check my tiny web component that does exactly that. ;)
Python 3 ready!
Now you can install this module with pip! Yeah! :D
pip install cpf-cnpj-validate
To use pycpfcnpj is simples like as every python module should be!
from pycpfcnpj import cpfcnpj
cpf_number = '11144477735'
masked_cpf_number = '111.444.777-35'
cnpj_number = '11444777000161'
masked_cnpj_number = '11.444.777/0001-61'
print cpfcnpj.validate(cpf_number)
print cpfcnpj.validate(masked_cpf_number)
print cpfcnpj.validate(cnpj_number)
print cpfcnpj.validate(masked_cnpj_number)
Expected output:
>>>True
>>>True
>>>True
>>>True
Simple like that. =)
You can use, as well, the cpf and cnpj packages. The cpfcnpj is like a Facade to the other modules. Make yourself confortable.
Oh, fork and contribute either if you want to.
Obs.: There is no dependencies.
Oh, and before I forget, You can generate, only and only for test purposes, a CPF or CNPJ number using the 'gen' module. Easy like above:
from pycpfcnpj import gen
gen.cpf()
gen.cnpj()
Expected output:
>>> 49384063495
>>> 20788274885880
And you also can generate CPF or CǸPJ with punctuation marks. :)
from pycpfcnpj import gen
gen.cpf_with_punctuation()
gen.cnpj_with_punctuation()
Expected output:
>>> 048.891.866-97
>>> 63.212.638/0361-35
And you also can format a cpf or cnpj number with valid mask
from pycpfcnpj import mask
only_number_cnpj: str = "63212638036135"
with_mask_cnpj: str = mask.mask_cpf_cnpj(only_number_cnpj)
only_number_cpf: int = 4889186697
with_mask_cpf: str = mask.mask_cpf_cnpj(only_number_cpf)
print(with_mask_cnpj)
print(with_mask_cpf)
Expected output:
>>> 63.212.638/0361-35
>>> 048.891.866-97
Have fun!
Módulo python para validar números de CPF e CNPJ.
Agora você pode instalar o pycpfcnpj usando o pip!\m/
pip install cpf-cnpj-validate
from pycpfcnpj import cpfcnpj
cpf_number = '11144477735'
masked_cpf_number = '111.444.777-35'
cnpj_number = '11444777000161'
masked_cnpj_number = '11.444.777/0001-61'
print cpfcnpj.validate(cpf_number)
print cpfcnpj.validate(cpf_number_mascara)
print cpfcnpj.validate(cnpj_number)
print cpfcnpj.validate(cnpj_number_mascara)
Expected output:
>>>True
>>>True
>>>True
>>>True
Simples assim! Você também pode usar os pacotes internos que tratam em separado os números de CPF e CNPJ. O módulo 'cpfcnpj' é um tipo de interface para os módulos mais especificos e se encarrega de saber quando você está passando um CPF ou um CNPJ.
Fique à vontade em contribuir com o projeto ou da maneira que quiser. Ah, sim: pure python (sem dependências ;) ).
Ah, e antes que eu me esqueça, você pode gerar, só e apenas somente para fins de teste, um número de CPF ou CNPJ utilizando o módulo 'gen'. Fácil como acima:
from pycpfcnpj import gen
gen.cpf()
gen.cnpj()
Expected output:
>>> 49384063495
>>> 20788274885880
E você também pode gerar CPF ou CNPJ com pontuação :)
from pycpfcnpj import gen
gen.cpf_with_punctuation()
gen.cnpj_with_punctuation()
Expected output:
>>> 048.891.866-97
>>> 63.212.638/0361-35
Divirta-se!
1.6.0
1.1
1.2
sys
rather than six
to check python's version and keeps this project 100% free of dependencies.1.3
1.4
1.5
1.5.1
1.6.0
1.1
1.2
sys
em vez do six
para verificar a versão do Python e evitando o uso de libs terceiras1.3
1.4
1.5
1.5.1
FAQs
Python module for brazilian register numbers for persons (CPF) and companies (CNPJ) and mask generator to string or int CPF/CNPJ.
We found that cpf-cnpj-validate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.