Created
September 21, 2022 17:33
-
-
Save MuriloAkita/53e6e0eb101e4151bea976ff660c9c46 to your computer and use it in GitHub Desktop.
CPF Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Gerador de CPF válido feito em Python. | |
Por Murilo Akita | |
Github: https://github.com/MuriloAkita | |
""" | |
from random import randint | |
def digit_equation(cpf): | |
while len(cpf) != 11: | |
summation = 0 | |
digit = 0 | |
range_number = len(cpf) + 1 | |
for i, n in enumerate(range(range_number, 1, -1)): | |
summation = summation + (int(cpf[i]) * n) | |
remainder = 11 - (summation % 11) | |
if remainder <= 9: | |
digit = remainder | |
cpf += str(digit) | |
else: | |
return cpf | |
number = str(randint(100000000, 999999999)) | |
validated_cpf = digit_equation(number) | |
print(validated_cpf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment