JsonDataMasking 1.2.2
See the version list below for details.
dotnet add package JsonDataMasking --version 1.2.2
NuGet\Install-Package JsonDataMasking -Version 1.2.2
<PackageReference Include="JsonDataMasking" Version="1.2.2" />
paket add JsonDataMasking --version 1.2.2
#r "nuget: JsonDataMasking, 1.2.2"
// Install JsonDataMasking as a Cake Addin #addin nuget:?package=JsonDataMasking&version=1.2.2 // Install JsonDataMasking as a Cake Tool #tool nuget:?package=JsonDataMasking&version=1.2.2
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 or, call directly theJsonMaskSerializer.Serialize()
to mask your data and serialize your object withSystem.Text.Json
's serializer.
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.
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);
var maskedDataSerialized = JsonMaskSerializer.Serialize(data);
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
- System.Text.Json (>= 6.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.