Walter.Cypher.Native.Json 2025.3.13.1306

Prefix Reserved
dotnet add package Walter.Cypher.Native.Json --version 2025.3.13.1306
                    
NuGet\Install-Package Walter.Cypher.Native.Json -Version 2025.3.13.1306
                    
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="Walter.Cypher.Native.Json" Version="2025.3.13.1306" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Walter.Cypher.Native.Json" Version="2025.3.13.1306" />
                    
Directory.Packages.props
<PackageReference Include="Walter.Cypher.Native.Json" />
                    
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 Walter.Cypher.Native.Json --version 2025.3.13.1306
                    
#r "nuget: Walter.Cypher.Native.Json, 2025.3.13.1306"
                    
#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.
#addin nuget:?package=Walter.Cypher.Native.Json&version=2025.3.13.1306
                    
Install Walter.Cypher.Native.Json as a Cake Addin
#tool nuget:?package=Walter.Cypher.Native.Json&version=2025.3.13.1306
                    
Install Walter.Cypher.Native.Json as a Cake Tool

WALTER

Introducing the WALTER Framework: Workable Algorithms for Location-aware Transmission, Encryption Response. Designed for modern developers, WALTER is a groundbreaking suite of NuGet packages crafted for excellence in .NET Standard 2.0, 2.1, Core 3.1, and .NET 6, 7, 8, as well as C++ environments. Emphasizing 100% AoT support and reflection-free operations, this framework is the epitome of performance and stability.

Whether you're tackling networking, encryption, or secure communication, WALTER offers unparalleled efficiency and precision in processing, making it an essential tool for developers who prioritize speed and memory management in their applications.

About the Walter.Cypher.Native.Json Nuget Package

The Walter.Cypher.Native.Json NuGet package provides a set of custom converters designed to enhance the security and privacy of your .NET applications by protecting sensitive data, especially useful in adhering to GDPR requirements. These converters can be easily integrated with the System.Text.Json serialization and deserialization process, obfuscating sensitive information such as IP addresses, strings, dates, and numbers. The online help can be viewed using https://walter_cypher_newtonsoft_json.asp-waf.com. Github samples are at https://github.com/vesnx/Walter.Cypher.Native.Json

Available Converters

  • GDPRCollectionOfStringConverter: Protects GDPR sensitive string collections, ideal for personal data like email lists.
  • GDPRIPAddressConverter: Obfuscates IP addresses to ensure privacy and compliance.
  • GDPRIPAddressListConverter: Safeguards lists of IP addresses, useful for configuration data or logging.
  • GDPRObfuscatedDateTimeConverter: Obfuscates dates, suitable for sensitive date information like birthdates or issue dates.
  • GDPRObfuscatedStringConverter: General purpose obfuscation for single strings, applicable to names, credit card numbers, etc.
  • GDPRObfuscatedIntConverter: Protects sensitive integer values, such as credit card CCVs.

Getting Started

To use this package, first install it via NuGet


Install-Package Walter.Cypher.Native.Json

Working with a Android symulator

The native package is not compatible with the android symulator so if you are not using the package to accept data from or send data to a android simulator set

Walter.Native.Wrapper.SymmetricEncryption.ArmSimulatorCompatible = false

Use Case: Secure User Profile Serialization

This example demonstrates configuring System.Text.Json to use the provided GDPR converters for both serialization and deserialization processes, ensuring that sensitive data is adequately protected according to GDPR guidelines.

You can integrate the converters as show below where we configure the json serializer native context to use a few of the GDPR converters


    [JsonSerializable(typeof(UserProfile))]
    [JsonSourceGenerationOptions(
            GenerationMode = JsonSourceGenerationMode.Metadata,
            Converters = [typeof(GDPRIPAddressListConverter), typeof(GDPRObfuscatedStringConverter), typeof(GDPRObfuscatedIntConverter),typeof(GDPRObfuscatedDateTimeConverter) ],
            DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault,
            PropertyNameCaseInsensitive = true,
            PreferredObjectCreationHandling = JsonObjectCreationHandling.Populate,
            WriteIndented = true
)]
    partial class UserProfileDataConverter : System.Text.Json.Serialization.JsonSerializerContext
    {
    }

You can then use these converters in a class or record, the bellow sample uses a combination of property names and converters to remove any inferable information from the json string

    internal record UserProfile
    {
        [JsonPropertyName("a")]
        [JsonConverter(typeof(GDPRObfuscatedStringConverter))]
        public required string Name { get; set; }

        [JsonPropertyName("b")]
        [JsonConverter(typeof(GDPRObfuscatedStringConverter))]
        public required string Email { get; set; }

        [JsonPropertyName("c")]
        [JsonConverter(typeof(GDPRObfuscatedDateTimeConverter))]
        public DateTime DateOfBirth { get; set; }

        [JsonPropertyName("d")]
        [JsonConverter(typeof(GDPRIPAddressListConverter))]
        public List<IPAddress> Devices { get; set; } = [];
    }

First we will use DI to integrate the Walter framework and use a shared secret password

   //secure the json using a protected password
   using var service = new ServiceCollection()
                           .AddLogging(option =>
                           {
                               //configure your logging as you would normally do
                               option.AddConsole();
                               option.SetMinimumLevel(LogLevel.Information);
                           })
                           .UseSymmetricEncryption("May$ecr!tPa$$w0rd")                                    
                           .BuildServiceProvider();

   service.AddLoggingForWalter();//enable logging for the Walter framework classes

Serializing and Deserializing Securely

Use the UserProfileDataConverter for serialization and deserialization, ensuring data is encrypted and obfuscated according to the converters' specifications.

           /*
           save to json and store or send to a insecure location the profile to disk. 
           note that data in transit can be read even if TLS secured using proxy or man in the middle. 
            */
           var profile = new UserProfile() { 
               Email = "My@email.com", 
               Name = "Jo Coder", 
               DateOfBirth = new DateTime(2001, 7, 16), 
               Devices=[IPAddress.Parse("192.168.1.1"),IPAddress.Parse("192.168.1.14"), IPAddress.Loopback]
           };

           var json= System.Text.Json.JsonSerializer.Serialize(profile, UserProfileDataConverter.Default.UserProfile);
           var directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MySupperApp");
           var fileName = Path.Combine(directory, "Data1.json");
           if (!Directory.Exists(directory))
           {
               Directory.CreateDirectory(directory);
           }

           //use inversion of control and generate a ILogger without dependency injection
           Inverse.GetLogger("MyConsoleApp")?.LogInformation("Cyphered json:\n{json}", json);


           await File.WriteAllTextAsync(fileName, json).ConfigureAwait(false);

Reading and Validating Data

Read the encrypted JSON from storage or after transmission, and deserialize it back into the UserProfile class, automatically decrypting and validating the data.

var cypheredJson = await File.ReadAllTextAsync("path_to_encrypted_json").ConfigureAwait(false);

if (cypheredJson.IsValidJson<UserProfile>(UserProfileDataConverter.Default.UserProfile, out var user))
{
   // Use the deserialized and decrypted `user` object
}

A working copy for use in a console application

The following is a working example of how you could use this in a console application

 //secure the json using a protected password
 using var service = new ServiceCollection()
                         .AddLogging(option =>
                         {
                             //configure your logging as you would normally do
                             option.AddConsole();
                             option.SetMinimumLevel(LogLevel.Information);
                         })
                         .UseSymmetricEncryption("May$ecr!tPa$$w0rd")                                    
                         .BuildServiceProvider();

 service.AddLoggingForWalter();//enable logging for the Walter framework classes




 //... rest of your code 
 
 /*
 save to json and store or send to a insecure location the profile to disk. 
 Data in transit can be read even if TLS secured using proxy or man in the middle. 

  */
 var profile = new UserProfile() { 
     Email = "My@email.com", 
     Name = "Jo Coder", 
     DateOfBirth = new DateTime(2001, 7, 16), 
     Devices=[IPAddress.Parse("192.168.1.1"),IPAddress.Parse("192.168.1.14"), IPAddress.Loopback]
 };

 var json= System.Text.Json.JsonSerializer.Serialize(profile, UserProfileDataConverter.Default.UserProfile);
 var fileName= Path.GetTempFileName();

 //use inversion of control and generate a ILogger without dependency injection
 Inverse.GetLogger("MyConsoleApp")?.LogInformation("Cyphered json:\n{json}", json);


 await File.WriteAllTextAsync(fileName, json).ConfigureAwait(false);

 //... rest of your code 


 /*
  Read the json back in to a class using this simple extension method
  */
 var cypheredJson= await File.ReadAllTextAsync(fileName).ConfigureAwait(false);

 //use string extension method to generate json from a string
 if (cypheredJson.IsValidJson<UserProfile>(UserProfileDataConverter.Default.UserProfile, out UserProfile? user))
 { 
     //... user is not null and holds decrypted values as the console will show
     Inverse.GetLogger("MyConsoleApp")?.LogInformation("Profile:\n{profile}", user.ToString());
 }

 if(File.Exists(fileName))
 { 

     File.Delete(fileName);
 }

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst18.0 is compatible.  net8.0-macos was computed.  net8.0-macos15.0 is compatible.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 is compatible.  net9.0-android was computed.  net9.0-android35.0 is compatible.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst was computed.  net9.0-maccatalyst18.0 is compatible.  net9.0-macos was computed.  net9.0-macos15.0 is compatible.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2025.3.13.1306 132 3/13/2025
2025.2.26.1548 101 2/26/2025
2025.2.15.1301 96 2/15/2025
2025.1.16.1405 83 1/16/2025
2024.11.30.1709 109 12/13/2024
2024.11.28.1622 102 11/28/2024
2024.11.20.1316 105 11/21/2024
2024.11.14.1710 96 11/14/2024
2024.11.6.1222 105 11/6/2024
2024.10.28.1605 96 10/28/2024
2024.10.28.1335 92 10/28/2024
2024.10.19.1525 105 10/20/2024
2024.9.17.1417 108 9/17/2024
2024.9.12.1923 110 9/12/2024
2024.9.6.1352 167 9/7/2024
2024.9.4.1300 142 9/4/2024
2024.9.1.1143 118 9/1/2024
2024.8.19.1400 140 8/19/2024
2024.8.14.1256 138 8/14/2024
2024.8.12.958 120 8/12/2024
2024.8.5.1010 90 8/5/2024
2024.7.26.543 76 7/26/2024
2024.7.11.1604 115 7/11/2024
2024.7.9.1509 118 7/9/2024
2024.7.4.1424 113 7/4/2024
2024.7.3.1001 99 7/3/2024
2024.6.26.1408 120 6/28/2024
2024.6.6.1320 126 6/8/2024
2024.5.15.1634 117 5/15/2024
2024.5.14.829 118 5/14/2024
2024.5.13.1637 113 5/13/2024
2024.5.8.1005 128 5/8/2024
2024.4.4.2102 139 4/4/2024
2024.3.26.1111 135 3/26/2024
2024.3.19.2310 146 3/19/2024
2024.3.12.1022 139 3/12/2024
2024.3.7.836 141 3/7/2024
2024.3.6.1645 136 3/6/2024
2024.3.3.842 135 3/3/2024
2024.3.3.750 124 3/3/2024
2024.3.1.1143 135 3/1/2024
2024.2.27.1029 138 2/27/2024
2021.10.9.1116 99 10/9/2024

12 Mar 2025
-Update NuGet dependencies that have vulnerabilities

26 Feb 2025
- Update package references

11 June 2024
- Update DSK build

2 April 2024
- Update to 8.0.3

22 February 2024
- AoT compatible secure json processing