Byndyusoft.MaskedSerialization.Core 2.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Byndyusoft.MaskedSerialization.Core --version 2.1.2                
NuGet\Install-Package Byndyusoft.MaskedSerialization.Core -Version 2.1.2                
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="Byndyusoft.MaskedSerialization.Core" Version="2.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Byndyusoft.MaskedSerialization.Core --version 2.1.2                
#r "nuget: Byndyusoft.MaskedSerialization.Core, 2.1.2"                
#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.
// Install Byndyusoft.MaskedSerialization.Core as a Cake Addin
#addin nuget:?package=Byndyusoft.MaskedSerialization.Core&version=2.1.2

// Install Byndyusoft.MaskedSerialization.Core as a Cake Tool
#tool nuget:?package=Byndyusoft.MaskedSerialization.Core&version=2.1.2                

Byndyusoft.MaskedSerialization Nuget Downloads

A tool to mask sensitive data during serialization with the System.Text.Json package

Installing

dotnet add package Byndyusoft.MaskedSerialization

Usage

If you use System.Text.Json to serialize data, use [Masked] attribute to mark properties that should be masked. Example:

  public class CompanyDto
  {
      public string Name { get; set; } = default!;

      [Masked]
      public string SecretOwner { get; set; } = default!;

      public IncomeDto WhiteIncome { get; set; } = default!;

      [Masked]
      public IncomeDto GreyIncome { get; set; } = default!;
  }

  public class IncomeDto
  {
      public string Description { get; set; } = default!;

      [Masked]
      public long SumInDollars { get; set; }
  }

Values of properties SecretOwner and GreyIncome of class CompanyDto will be masked with value "*". Here is an example of simple usage:

  var dto = new CompanyDto
                {
                    Name = "Mega Big Company",
                    SecretOwner = "Navalov",
                    WhiteIncome = new IncomeDto
                                      {
                                          Description = "White",
                                          SumInDollars = 1000000
                                      },
                    GreyIncome = new IncomeDto
                                     {
                                         Description = "Black",
                                         SumInDollars = 1000000000
                                     }
                };

  var serialized = MaskedSerializationHelper.SerializeWithMasking(dto);

The result will be:

{
   "Name":"Mega Big Company",
   "SecretOwner":"*",
   "WhiteIncome":{
      "Description":"White",
      "SumInDollars":"*"
   },
   "GreyIncome":"*"
}

You can setup serializer options to enable masking. Another usage example:

  var options = new JsonSerializerOptions();
  MaskedSerializationHelper.SetupSettingsForMaskedSerialization(options);
  var serialized = JsonSerializer.Serialize(dto, options);

Not implemented System.Text.Json annotations

If a type has at least one property with the [Masked] attribute, then annotation attributes will be ignored during serialization of objects of this type. For example, those are [JsonIgnore], [JsonPropertyName(...)], [JsonInclude], [JsonConverter(...)] etc.

Byndyusoft.MaskedSerialization.Newtonsoft Nuget Downloads

A tool to mask sensitive data during serialization with Newtonsoft.Json

Installing

dotnet add package Byndyusoft.MaskedSerialization.Newtonsoft

Usage

If you use Newtonsoft.Json to serialize data, use [Masked] attribute to mark properties that should be masked. Usage example:

  var serialized = MaskedSerializationHelper.SerializeWithMasking(dto);
  // Another usage example
  var settings = new JsonSerializerSettings();
  MaskedSerializationHelper.SetupSettingsForMaskedSerialization(settings);
  var serialized = JsonConvert.SerializeObject(dto, settings);

Byndyusoft.MaskedSerialization.Serilog Nuget Downloads

A tool to mask sensitive destructured data in logging with Serilog

Installing

dotnet add package Byndyusoft.MaskedSerialization.Serilog

Usage

You can setup logger configuration to use destructure masking policy:

  var loggerConfiguration = new LoggerConfiguration().WithMaskingPolicy().WriteTo.Console();

Here is an example of simple usage:

public class Service
{
  private readonly ILogger<Service> _logger;

  public Service(ILogger<Service> logger)
  {
    _logger = logger;
  }

  public void LogCompany()
  {
    var dto = new CompanyDto
                  {
                      Name = "Mega Big Company",
                      SecretOwner = "Navalov",
                      WhiteIncome = new IncomeDto
                                        {
                                            Description = "White",
                                            SumInDollars = 1000000
                                        },
                      GreyIncome = new IncomeDto
                                       {
                                           Description = "Black",
                                           SumInDollars = 1000000000
                                       }
                  };
    
    _logger.LogInformation("Used company {@CompanyDto}", dto);
  }
}

The output in the console will be:

  [10:47:31 INF] Used company {"Name": "Mega Big Company", "SecretOwner": "*", "WhiteIncome": {"Description": "White", "SumInDollars": "*", "$type": "IncomeDto"}, "GreyIncome": "*", "$type": "CompanyDto"}

Contributing

To contribute, you will need to setup your local environment, see prerequisites. For a contribution and workflow guide, see package development lifecycle.

A detailed overview on how to contribute can be found in the contributing guide.

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Package development lifecycle

  • Implement package logic in src
  • Add or adapt unit-tests in tests
  • Add or change the documentation as needed
  • Open pull request for a correct branch. Target the project's master branch

Maintainers

github.maintain@byndyusoft.com

Product 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Byndyusoft.MaskedSerialization.Core:

Package Downloads
Byndyusoft.MaskedSerialization.Newtonsoft

Package Description

Byndyusoft.MaskedSerialization.Serilog

Package Description

Byndyusoft.MaskedSerialization

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 422 1/26/2024
2.1.2 325 9/8/2023
2.1.1 260 9/8/2023
2.1.0 9,538 8/5/2022
2.0.0 3,444 3/3/2022
1.1.0-alpha 316 2/25/2022