Skip to content

Instantly share code, notes, and snippets.

@ProbablePrime
Created September 23, 2025 20:28
Show Gist options
  • Select an option

  • Save ProbablePrime/3e45739ef10b178ef572998c3cce12fc to your computer and use it in GitHub Desktop.

Select an option

Save ProbablePrime/3e45739ef10b178ef572998c3cce12fc to your computer and use it in GitHub Desktop.
A Microsoft.Extensions.Compliance.Redaction that redacts secrets replacing them with "CHEESE"
using Microsoft.Extensions.Compliance.Redaction;
using System;
namespace Cheese;
public class CheeseRedactor : Redactor
{
private const string CHEESE = nameof(CHEESE);
public override int GetRedactedLength(ReadOnlySpan<char> input) => input.Length;
public override int Redact(ReadOnlySpan<char> source, Span<char> destination)
{
for (int i = 0; i < destination.Length; i++)
{
destination[i] = CHEESE[i % CHEESE.Length];
}
return destination.Length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment