Giter VIP home page Giter VIP logo

json-data-masking's Introduction

NuGet Version CI

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:

  1. 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 to false.
    • 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.
  2. 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

json-data-masking's People

Contributors

luizaes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.