Maskify.Core
1.1.1
See the version list below for details.
dotnet add package Maskify.Core --version 1.1.1
NuGet\Install-Package Maskify.Core -Version 1.1.1
<PackageReference Include="Maskify.Core" Version="1.1.1" />
<PackageVersion Include="Maskify.Core" Version="1.1.1" />
<PackageReference Include="Maskify.Core" />
paket add Maskify.Core --version 1.1.1
#r "nuget: Maskify.Core, 1.1.1"
#:package Maskify.Core@1.1.1
#addin nuget:?package=Maskify.Core&version=1.1.1
#tool nuget:?package=Maskify.Core&version=1.1.1
Maskify - Sensitive Data Masking Library
Maskify is a lightweight, efficient, and flexible library designed to help developers securely mask sensitive data such as Brazilian documents (CPF, CNPJ), emails, credit cards, and more. It provides out-of-the-box masking for common data types and customizable masking options for any other sensitive information, ensuring compliance with data protection regulations like LGPD.
Key Features
- CPF Masking: Effortlessly masks CPF numbers, formatted or unformatted.
- CNPJ Masking: Supports CNPJ numbers, both masked and unmasked.
- Email Masking: Partially hides email addresses, maintaining domain visibility.
- Credit Card Masking: Safely masks credit card numbers, including support for:
- Standard 16-digit cards.
- American Express (15 digits).
- Diners Club (14 digits).
- Generic Masking Method: Enables masking of any sensitive data (e.g., phone numbers, addresses) with full control over visible characters and masking character.
- Customizable Masking: Define your own masking rules by selecting the number of visible characters and masking symbols (e.g.,
*,#).
Installation
Install Maskify via NuGet Package Manager:
dotnet add package Maskify
You can also visit the NuGet page for more information.
Usage Guide
1. Mask CPF
Mask Brazilian CPF numbers, allowing input with or without formatting:
using Maskify.Core;
string cpf = "123.456.789-10";
string maskedCpf = Masker.MaskCPF(cpf);
Console.WriteLine(maskedCpf); // Output: ***.***.***-10
2. Mask CNPJ
Supports masking of CNPJ numbers, accepting both formatted and unformatted inputs:
using Maskify.Core;
string cnpj = "12.345.678/0001-99";
string maskedCnpj = Masker.MaskCNPJ(cnpj);
Console.WriteLine(maskedCnpj); // Output: **.***.***/0001-99
3. Mask Email
Partially hide sensitive portions of email addresses, preserving the domain:
using Maskify.Core;
string email = "user@example.com";
string maskedEmail = Masker.MaskEmail(email);
Console.WriteLine(maskedEmail); // Output: use****@example.com
4. Mask Credit Cards
Mask credit card numbers, including support for standard, Amex, and Diners Club cards:
using Maskify.Core;
// Masking a standard 16-digit card
string maskedCreditCard = "1234 5678 9012 3456".MaskCreditCard();
Console.WriteLine(maskedCreditCard); // Output: "**** **** **** 3456"
// Masking an American Express card (15 digits)
string maskedAmex = "3782 822463 10005".MaskCreditCard('#');
Console.WriteLine(maskedAmex); // Output: "#### ###### #0005"
// Masking a Diners Club card (14 digits)
string maskedDinersClub = "3056 9304 5567 89".MaskCreditCard();
Console.WriteLine(maskedDinersClub); // Output: "**** **** **67 89"
5. Mask Custom Data
Use the generic method to mask any sensitive data, such as phone numbers or custom fields:
using Maskify.Core;
string sensitiveData = "Sensitive Info";
string maskedData = Masker.Mask(sensitiveData, 3, 4, '*');
Console.WriteLine(maskedData); // Output: Sen***********Info
In this example:
startPositiondefines the number of visible characters at the beginning.lengthdefines the number of characters to mask after the start position.charis the character used to mask the sensitive portion (e.g.,*,#).
6. Customizable Masking
You can fully customize the masking behavior by specifying the number of characters to keep visible at both the start and end of the string, as well as the masking symbol:
using Maskify.Core;
string phoneNumber = "555-1234-5678";
string maskedPhone = Masker.Mask(phoneNumber, 4, 3, '#');
Console.WriteLine(maskedPhone); // Output: 555-#######5678
Advanced Features (v1.1.1)
With the latest version of Maskify (v1.1.1), new functionality has been added:
Credit Card Masking
Added support for masking different types of credit cards:
- Standard 16-digit cards: Common format used by Visa, MasterCard, etc.
- American Express (Amex): 15-digit cards, with specific masking rules.
- Diners Club: 14-digit cards.
Example for credit card masking:
using Maskify.Core;
// Masking a standard credit card
string maskedCard = "4111 1111 1111 1111".MaskCreditCard();
Console.WriteLine(maskedCard); // Output: **** **** **** 1111
Version History
v1.1.1 (October 2024)
New Features:
- Credit Card Masking: Supports standard 16-digit, Amex 15-digit, and Diners Club 14-digit card formats.
Improvements:
- Improved handling of CPF and CNPJ inputs, now accepting both formatted and unformatted data.
Bug Fixes:
- Fixed inconsistencies in email masking patterns for various formats.
Contributing
We welcome all contributions! Whether you want to fix a bug, improve performance, or add new features, feel free to submit a pull request or open an issue on our GitHub repository.
License
This project is licensed under the terms of the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.