{"id":26191008,"url":"https://github.com/diggosilva/cpfcnpjtools","last_synced_at":"2025-07-31T09:33:01.323Z","repository":{"id":263312495,"uuid":"889206885","full_name":"diggosilva/CPFCNPJTools","owner":"diggosilva","description":"A iOS application written in Swift, this project is a library for CocoaPods that allows you to validate, generate and manipulate CPF and CNPJ numbers","archived":false,"fork":false,"pushed_at":"2024-12-23T15:28:45.000Z","size":167,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T12:49:12.330Z","etag":null,"topics":["cocoapods","ios","smp","swift","swift-package-manager","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diggosilva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-15T20:22:25.000Z","updated_at":"2024-12-23T15:07:18.000Z","dependencies_parsed_at":"2024-12-17T14:31:39.708Z","dependency_job_id":null,"html_url":"https://github.com/diggosilva/CPFCNPJTools","commit_stats":null,"previous_names":["diggosilva/cpf-cnpj-tools","diggosilva/cpfcnpjtools"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diggosilva%2FCPFCNPJTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diggosilva%2FCPFCNPJTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diggosilva%2FCPFCNPJTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diggosilva%2FCPFCNPJTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diggosilva","download_url":"https://codeload.github.com/diggosilva/CPFCNPJTools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243136044,"owners_count":20241989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","ios","smp","swift","swift-package-manager","xcode"],"created_at":"2025-03-12T00:59:07.340Z","updated_at":"2025-03-12T00:59:07.970Z","avatar_url":"https://github.com/diggosilva.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPFCNPJTools\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.9.1-orange.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Xcode-15.2.X-orange.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/platforms-iOS-brightgreen.svg?style=flat\" alt=\"iOS\" /\u003e\n    \u003ca href=\"https://www.linkedin.com/in/rodrigo-silva-6a53ba300/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/LinkedIn-@RodrigoSilva-blue.svg?style=flat\" alt=\"LinkedIn: @RodrigoSilva\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nA iOS application written in Swift, this project is a library for CocoaPods that allows you to validate, generate and manipulate CPF and CNPJ numbers in a simple and efficient way. Ideal for testing and filling out forms.\n\n## Difference between (CPF), (CNPJ) and (CNPJ Alphanumeric)\n\n- CPF (Individual Taxpayer Registry): The CPF is an individual registration number used by the Brazilian Federal Revenue Service to identify an individual. The CPF is made up of 11 digits (XXX.XXX.XXX-XX). It is used for various purposes, such as opening bank accounts, issuing invoices, and filing taxes.\n\n- CNPJ (National Registry of Legal Entities): The CNPJ is a registration number used by the Brazilian Federal Revenue Service to identify companies or other legal entities. The CNPJ is made up of 14 digits (XX.XXX.XXX/0001-XX). It is used to formalize the existence of a company, allowing it to carry out commercial activities, such as issuing invoices, paying taxes, among others.\n\n- In view of the continuous growth in the number of companies and the imminent exhaustion of available CNPJ numbers, the Brazilian Federal Revenue Service is launching the **Alphanumeric CNPJ**. This solution aims to facilitate the identification of all companies and improve the business environment, contributing to the economic and social development of Brazil.\n\n- The **Alphanumeric CNPJ will be assigned, starting in July 2026**, exclusively to new registrations. Existing CNPJ numbers will not undergo any change, that is, **those who are already registered with the CNPJ will keep their number valid!**\n\n## Contents\n\n- [Requirements](#requirements)\n- [Functionalities](#functionalities)\n- [Instalation](#instalation)\n- [How to use](#howToUse)\n- [Credits](#credits)\n\n## Requirements\n\n- iOS 17.0 or later\n- Xcode 15.0 or later\n- Swift 5.0 or later\n\n## Functionalities\n\n- [x] CPF Validation: Check if a CPF number is valid, following the rules of the Federal Revenue Service.\n- [x] CNPJ Validation: Check if a CNPJ number is valid, according to tax rules.\n- [x] CNPJ Alphanumeric Validation: Check if a CNPJ Alphanumeric is valid, according to tax rules.\n- [x] Fake CPF generation: Generate a valid CPF number randomly.\n- [x] Fake CNPJ generation: Generate a valid CNPJ number randomly.\n- [x] Fake CNPJ Alphanumeric generation: Generate a valid CNPJ Alphanumeric randomly.\n\n## Instalation with Cocoapods\n\nAdd the dependency to your Podfile:\n\n```sh\n$ pod 'CPFCNPJTools'\n```\n\nThen run:\n\n```sh\n$ pod install\n```\n\n## Instalation with (SPM) - Swift Package Manager (Xcode 11+)\n\n[Swift Package Manager (SPM)](https://www.swift.org/documentation/package-manager) is a tool for managing the distribution of Swift code as well as C-family dependency. From Xcode 11, SwiftPM got natively integrated with Xcode.\n\nCPFCNPJTools support SPM from version 5.1.0. To use SPM, you should use Xcode to open your project. Click `File` -\u003e `Add Package Dependencies`, enter [CPFCNPJTools repo's URL](https://github.com/diggosilva/CPFCNPJTools). \n\n## HowToUse\n\n# CPF\n\n### 1.1 Validate CPF\n\n- To validate a CPF, simply use the `validate(cpf: String) -\u003e CPFStatus` method:\n\n```swift\nlet cpfManager = CPFManager()\nlet status = cpfManager.validate(cpf: \"11144477735\")\nprint(status) // .valid, .invalid, .cpfNull, .equalDigits or .invalidFormat\n ```\n\n### 1.2 Generate Fake CPF masked\n\n- To generate a fake CPF with mask, simply use the `generateMasked()` method:\n\n```swift\nlet cpfManager = CPFManager()\nlet fakeCPFMasked = cpfManager.generateMasked()\nprint(fakeCPFMasked) // \"111.444.777-35\"  // Randomly generated CPF\n```\n\n# CNPJ\n\n### 2.1 Validate CNPJ\n\n- To validate a CNPJ, simply use the `validate(cnpj: String) -\u003e CNPJStatus)` method:\n\n```swift\nlet cnpjManager = CNPJManager()\nlet status = cnpjManager.validate(cnpj: \"11444777000135\")\nprint(status) // .valid, .invalid, .cnpjNull, .equalDigits or .invalidFormat\n```\n\n### 2.2 Generate Fake CNPJ masked\n\n```swift\nlet cnpjManager = CNPJManager()\nlet fakeCNPJMasked = cnpjManager.generateMasked()\nprint(fakeCNPJMasked) // \"11.444.777/0001-35\"  // Randomly generated CNPJ\n```\n\n# CNPJ Alphanumeric\n\n### 3.1 Validate CNPJ Dual Format\n\n- To validate a CNPJ Alphanumeric, simply use the `validate(cnpjDualFormat: String) -\u003e CNPJDualFormatStatus` method:\n\n```swift\nlet cnpjDualFormatManager = CNPJDualFormatManager()\nlet status = cnpjDualFormatManager.validate(cnpjDualFormat: \"12ABC34501DE35\")\nprint(status)  // .valid, .invalid, .cnpjNull, .equalDigits or .invalidFormat\n```\n\n### 3.2 Generate Fake CNPJ Dual Format masked\n\n```swift\nlet cnpjDualFormatManager = CNPJDualFormatManager()\nlet fakeCNPJAlphaNum = cnpjDualFormatManager.generate()\nprint(fakeCNPJAlphaNum)  // \"12.ABC.345/01DE-35\"  // Randomly generated CNPJ Alphanumeric\n```\n\n# Notes:\n\n- The file is formatted in **Markdown** (`.md`), which is the standard for GitHub readme files.\n- The methods are clearly described, with code examples in Swift to show how to use the library.\n- The explanations and comments are all in English, making the documentation accessible to a wider audience.\n\nFeel free to tweak any parts of the documentation to fit your style or add any additional information that you think is important! \n\nIf you'd like any more changes or additions, let me know.\n\n# Credits\n\n- **Diggo Silva**\n- **Helio Mesquita**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiggosilva%2Fcpfcnpjtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiggosilva%2Fcpfcnpjtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiggosilva%2Fcpfcnpjtools/lists"}