JsonDataMasking 2.0.1
dotnet add package JsonDataMasking --version 2.0.1
NuGet\Install-Package JsonDataMasking -Version 2.0.1
<PackageReference Include="JsonDataMasking" Version="2.0.1" />
paket add JsonDataMasking --version 2.0.1
#r "nuget: JsonDataMasking, 2.0.1"
// Install JsonDataMasking as a Cake Addin #addin nuget:?package=JsonDataMasking&version=2.0.1 // Install JsonDataMasking as a Cake Tool #tool nuget:?package=JsonDataMasking&version=2.0.1
JSON Data Masking
JSON Data Masking is a library for .NET Core applications that simplifies the masking process of PII/sensitive information.
Usage
After installing the Nuget package in your project, you need to take the following steps:
Add the
[SensitiveData]
attribute in your class properties to indicate what should be masked, and use its available fields to configure the masking:- PreserveLength: Set to
true
to keep the property length when masking its value. By default this setting is set tofalse
. - ShowFirst: If set, shows the first
N
characters of the property, not masking them. The default value is 0. - ShowLast: If set, shows the last
N
characters of the property, not masking them. The default value is 0. - SubstituteText: If set, the entire property value will be override with this text. Note that using this setting will ignore all other settings.
- Mask: Set to a character to use it when masking the property's value. By default, the character
*
is used.
- PreserveLength: Set to
Call the
JsonMask.MaskSensitiveData()
function, passing in your object instance as a parameter.
Support
This library supports masking of string
fields only, although it also supports List<string>
/IEnumerable<string>
and Dictionary<string, string>
. Nested class properties are also masked, independently of depth.
Property Type | Support |
---|---|
string | ✅ |
List<T>, where T is a class or string | ✅ |
IEnumerable<T>, where T is a class or string | ✅ |
Dictionary<string, string> | ✅ |
Any other collection type, such as Array, ArrayList<T>, etc | ❌ |
Any other base type different from string | ❌ |
Examples
Attributes
public class PropertiesExamples
{
/// 123456789 results in "*****"
[SensitiveData]
public string DefaultMask { get; set; }
/// 123456789 results in "REDACTED"
[SensitiveData(SubstituteText = "REDACTED")]
public string SubstituteMask { get; set; }
/// 123456789 results in "123*****789"
[SensitiveData(ShowFirst = 3, ShowLast = 3)]
public string ShowCharactersMask { get; set; }
/// 123456789 results in "#########"
[SensitiveData(PreserveLength = true, Mask = "#")]
public string PreserveCustomMask { get; set; }
}
Functions
var maskedData = JsonMask.MaskSensitiveData(data);
Dependencies
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- DeepCloner (>= 0.10.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.