EncineCarlos.Obfuscator
1.0.0
dotnet add package EncineCarlos.Obfuscator --version 1.0.0
NuGet\Install-Package EncineCarlos.Obfuscator -Version 1.0.0
<PackageReference Include="EncineCarlos.Obfuscator" Version="1.0.0" />
<PackageVersion Include="EncineCarlos.Obfuscator" Version="1.0.0" />
<PackageReference Include="EncineCarlos.Obfuscator" />
paket add EncineCarlos.Obfuscator --version 1.0.0
#r "nuget: EncineCarlos.Obfuscator, 1.0.0"
#:package EncineCarlos.Obfuscator@1.0.0
#addin nuget:?package=EncineCarlos.Obfuscator&version=1.0.0
#tool nuget:?package=EncineCarlos.Obfuscator&version=1.0.0
EncineCarlos.Obfuscator
A powerful and easy-to-use .NET library for obfuscating sensitive data in your applications. Automatically redacts properties marked with [SensitiveData] attribute using the Microsoft Extensions Compliance framework.
Features
✅ Attribute-based Obfuscation: Simply mark properties with [SensitiveData] attribute
✅ Nested Object Support: Recursively processes complex object hierarchies
✅ JSON Serialization: Returns clean JSON with sensitive data redacted
✅ JsonPropertyName Support: Respects [JsonPropertyName] attributes
✅ Microsoft Extensions Integration: Built on Microsoft.Extensions.Compliance framework
✅ Dependency Injection Ready: Easy integration with .NET DI container
✅ High Performance: Minimal overhead with reflection caching
Installation
dotnet add package EncineCarlos.Obfuscator
Quick Start
1. Mark sensitive properties with [SensitiveData]
public class User
{
public string Name { get; set; }
[SensitiveData]
public string Email { get; set; }
[SensitiveData]
public string Password { get; set; }
public int Age { get; set; }
[SensitiveData]
public decimal Salary { get; set; }
}
2. Register the service in your DI container
// Program.cs or Startup.cs
services.AddObfuscator();
3. Use the obfuscator service
public class MyController : ControllerBase
{
private readonly IObfuscatorService _obfuscator;
public MyController(IObfuscatorService obfuscator)
{
_obfuscator = obfuscator;
}
public IActionResult GetUser()
{
var user = new User
{
Name = "John Doe",
Email = "john@example.com",
Password = "secret123",
Age = 30,
Salary = 75000.50m
};
// Obfuscate sensitive data before logging or returning
var obfuscatedData = _obfuscator.ObfuscateSensitiveData(user);
_logger.LogInformation("User data: {UserData}", obfuscatedData);
return Ok(obfuscatedData);
}
}
Output
{
"Name": "John Doe",
"Email": "[REDACTED]",
"Password": "[REDACTED]",
"Age": 30,
"Salary": "[REDACTED]"
}
Advanced Usage
Nested Objects
The library automatically handles nested objects:
public class User
{
public string Name { get; set; }
[SensitiveData]
public string Email { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Street { get; set; }
[SensitiveData]
public string CreditCardNumber { get; set; }
public string City { get; set; }
}
JsonPropertyName Support
Respects [JsonPropertyName] attributes for consistent JSON output:
public class User
{
[JsonPropertyName("full_name")]
public string Name { get; set; }
[SensitiveData]
[JsonPropertyName("email_address")]
public string Email { get; set; }
}
Manual Usage (without DI)
var redactorProvider = new SimpleRedactorProvider();
var obfuscator = new ObfuscatorService(redactorProvider);
var result = obfuscator.ObfuscateSensitiveData(myObject);
Use Cases
- Logging: Remove sensitive data from logs
- API Responses: Clean data before sending to clients
- Debugging: Safe object inspection in development
- Compliance: GDPR, HIPAA, and other privacy regulations
- Data Export: Sanitize data for reports or analytics
Configuration
The library uses Microsoft.Extensions.Compliance for redaction. You can customize the redaction behavior:
services.AddRedaction(builder =>
{
builder.SetRedactor<MyCustomRedactor>(new DataClassificationSet());
});
Performance
The library is optimized for performance:
- Uses reflection caching internally
- Minimal memory allocations
- Supports high-throughput scenarios
Requirements
- .NET Standard 2.1 or higher
- Microsoft.Extensions.Compliance.Abstractions 9.8.0+
- Microsoft.Extensions.Compliance.Redaction 9.8.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
Made with ❤️ by Encine Carlos
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Compliance.Abstractions (>= 8.10.0)
- Microsoft.Extensions.Compliance.Redaction (>= 8.10.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- System.Text.Json (>= 8.0.6)
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 |
|---|---|---|
| 1.0.0 | 200 | 9/10/2025 |
v1.0.0:
- Initial release with full obfuscation functionality
- Support for JsonPropertyName attribute in property serialization
- Enhanced nested object handling for complex data structures
- Improved redaction capabilities using Microsoft Extensions Compliance
- Complete integration with dependency injection container
- Attribute-based obfuscation with [SensitiveData] marking