Maskify.Core 1.1.1

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Maskify.Core" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Maskify.Core" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Maskify.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Maskify.Core --version 1.1.1
                    
#r "nuget: Maskify.Core, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Maskify.Core@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Maskify.Core&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Maskify.Core&version=1.1.1
                    
Install as a Cake Tool

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:

  • startPosition defines the number of visible characters at the beginning.
  • length defines the number of characters to mask after the start position.
  • char is 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

NuGet Version

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.5.0 108 1/25/2026
1.4.3 98 1/24/2026
1.4.2 655 11/30/2024
1.4.1 226 10/28/2024
1.4.0 143 10/28/2024
1.3.3 148 10/26/2024
1.3.2 141 10/24/2024
1.3.1 151 10/23/2024
1.3.0 144 10/23/2024
1.2.1 231 10/23/2024
1.1.1 156 10/17/2024
1.0.0 972 10/16/2024