{"id":15206790,"url":"https://github.com/nikouu/zeroredact","last_synced_at":"2025-10-29T07:32:38.617Z","repository":{"id":257791784,"uuid":"861627389","full_name":"nikouu/ZeroRedact","owner":"nikouu","description":"A fast, simple, zero allocation redacting library for .NET, with no extra dependencies.","archived":false,"fork":false,"pushed_at":"2025-01-23T07:07:25.000Z","size":9587,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T07:03:29.799Z","etag":null,"topics":["benchmarking","csharp","dotnet","mask","masking","nuget","performance","redact","redaction"],"latest_commit_sha":null,"homepage":"https://nikouu.github.io/ZeroRedact/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikouu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"nikouusitalo"}},"created_at":"2024-09-23T08:46:17.000Z","updated_at":"2025-01-23T07:07:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"0d4a4d62-1f8e-40f6-a11d-939dbd9511fe","html_url":"https://github.com/nikouu/ZeroRedact","commit_stats":null,"previous_names":["nikouu/zeroredact"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikouu%2FZeroRedact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikouu%2FZeroRedact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikouu%2FZeroRedact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikouu%2FZeroRedact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikouu","download_url":"https://codeload.github.com/nikouu/ZeroRedact/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238791894,"owners_count":19531027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","csharp","dotnet","mask","masking","nuget","performance","redact","redaction"],"created_at":"2024-09-28T06:03:01.088Z","updated_at":"2025-10-29T07:32:38.611Z","avatar_url":"https://github.com/nikouu.png","language":"C#","funding_links":["https://ko-fi.com/nikouusitalo"],"categories":[],"sub_categories":[],"readme":"# ZeroRedact\n\n[![NuGet Downloads](https://img.shields.io/nuget/dt/Nikouu.ZeroRedact)](https://www.nuget.org/packages/Nikouu.ZeroRedact)\n[![NuGet](https://img.shields.io/nuget/v/Nikouu.ZeroRedact)](https://www.nuget.org/packages/Nikouu.ZeroRedact)\n[![GitHub Release](https://img.shields.io/github/v/release/nikouu/zeroredact)](https://github.com/nikouu/ZeroRedact/releases)\n[![Official Docs](https://img.shields.io/badge/Official_Docs-blue?logo=gitbook)](https://nikouu.github.io/ZeroRedact/)\n[![Demo](https://img.shields.io/badge/Demo-dd2257)](https://nikouu.github.io/ZeroRedact/demo/)\n[![GitHub License](https://img.shields.io/github/license/nikouu/zeroredact)](https://github.com/nikouu/ZeroRedact/blob/main/LICENSE)\n[![Blog](https://img.shields.io/badge/blog-nikouusitalo.com-8A2BE2)](https://www.nikouusitalo.com/)\n\nA fast, simple, zero allocation redacting library for .NET, with no non-Microsoft dependencies.\n\nFully or partially redact:\n- Strings\n- Email addresses\n- Credit card numbers\n- Dates\n- Phone numbers\n- IPV4 addresses\n- IPV6 addresses\n- MAC addresses\n\nRead more in the [official docs](https://nikouu.github.io/ZeroRedact/).\n\n## Getting started\n\nInstall via [NuGet](https://www.nuget.org/packages/Nikouu.ZeroRedact/):\n```\ndotnet add package Nikouu.ZeroRedact\n```\n\nThe following shows example redactions with varying configs. For more see the [official docs](https://nikouu.github.io/ZeroRedact/).\n\n```csharp\nvar redactor = new Redactor();\n\n// returns \"*************\"\nvar stringResult = redactor.RedactString(\"Hello, World!\");\n\n// returns \"*****@*******.***\"\nvar emailAddressResult = redactor.RedactEmailAddress(\"email@example.com\");\n\n// returns \"****-****-****-1111\"\nvar creditCardOptions = new CreditCardRedactorOptions { RedactorType = CreditCardRedaction.ShowLastFour };\nvar creditCardResult = redactor.RedactCreditCard(\"4111-1111-1111-1111\", creditCardOptions);\n\n// returns based on current culture\n// en-NZ: \"**/06/2023\"\n// en-US: \"6/**/2023\"\n// ja-JP: \"2023/06/**\"\n// InvariantCulture: \"06/**/2023\"\nvar dateOptions = new DateRedactorOptions { RedactorType = DateRedaction.Day };\nvar dateResult = redactor.RedactDate(new DateTime(2023, 6, 15), dateOptions);\n\n// returns \"###-###-####\"\nvar phoneNumberOptions = new PhoneNumberRedactorOptions { RedactionCharacter = '#' };\nvar phoneNumberResult = redactor.RedactPhoneNumber(\"212-456-7890\");\n\n// returns \"@@@.@.@.146\"\nvar ipv4AddressOptions = new IPv4AddressRedactorOptions\n{\n    RedactionCharacter = '@',\n    RedactorType = IPv4AddressRedaction.ShowLastOctet\n};\nvar ipv4Result = redactor.RedactIPv4Address(\"192.0.2.146\", ipv4AddressOptions);\n\n// returns \"****:****:****:****:****:****:****:****\"\nvar ipv6Result = redactor.RedactIPv6Address(\"2001:0000:130F:0000:0000:09C0:876A:130B\");\n\n// \"**:**:**:**:**:**\"\nvar macResult = redactor.RedactMACAddress(\"00:B0:D0:63:C2:26\");\n```\n\nOr in the case of a service registration with `IServiceCollection`:\n\n```csharp\n// Default\nbuilder.Services.AddZeroRedact();\n\n// Or to configure\nbuilder.Services.AddZeroRedact(new RedactorOptions\n{\n    CreditCardRedactorOptions = new CreditCardRedactorOptions { RedactorType = CreditCardRedaction.ShowLastFour },\n    EmailAddressRedactorOptions = new EmailAddressRedactorOptions { RedactorType = EmailAddressRedaction.ShowFirstCharacters },\n    DateRedactorOptions = new DateRedactorOptions { RedactorType = DateRedaction.Day },\n    PhoneNumberRedactorOptions = new PhoneNumberRedactorOptions { RedactorType = PhoneNumberRedaction.ShowLastFour }\n});\n```\n\n## Configuration\n\nZeroRedact can be configured in two ways: via constructor, and via a redaction method. Both using the appropriate redactor option object.\n\nConfiguration has three layers with least to most priority:\n1. Base defaults within the `Redactor` object.\n2. Passed in options to the `Redactor` object constructor\n3. Passed in options to a redaction method at the time of redaction\n\nThis example shows changing the base defaults. This will apply to every redaction, whether it's a string or email address, etc.\n\n```csharp\n// Example 1: Changing base defaults\nvar options = new RedactorOptions\n{\n    RedactionCharacter = 'X'\n};\n\nvar redactor = new Redactor(options);\n\n// returns \"XXXXXXXXXXXXX\"\nvar result = redactor.RedactString(\"Hello, World!\");\n```\n\nThis example shows `StringRedactorOptions` being passed into the `Redactor` constructor. Only string redactions will now use 'A' as the redaction character, all others will continue to use the default character of '*'.\n```csharp\n// Example 2: Changing specific redaction type options\nvar options = new RedactorOptions\n{\n    StringRedactorOptions = new StringRedactorOptions\n    {\n        RedactionCharacter = 'A'\n    }\n};\n\nvar redactor = new Redactor(options);\n\n// returns \"AAAAAAAAAAAAA\"\nvar result = redactor.RedactString(\"Hello, World!\");\n```\n\nThis example shows passing in `StringRedactorOptions` at the time of redaction, which takes precedence over the constructor options.\n```csharp\n// Example 3: Changing redaction options at redaction time\nvar options = new RedactorOptions\n{\n    StringRedactorOptions = new StringRedactorOptions\n    {\n        RedactionCharacter = 'A'\n    }\n};\n\nvar redactor = new Redactor(options);\nvar specificOptions = new StringRedactorOptions { RedactionCharacter = 'B' };\n\n// returns \"BBBBBBBBBBBBB\"\nvar result = redactor.RedactString(\"Hello, World!\", specificOptions);\n```\n\n## Layered configuration\n\nUsers should have a fine grained customization experience which allows for an easy to reuse item that can setup default behaviours but when needed, can adapt to the need of the redaction call at the time.\n\n## Error handling\n\nRedacting will not throw exceptions - that is, the string manipulation logic. Any exception during the redacting process will return a fixed length redaction with a default redacting character. This is to avoid disrupting the important real work happening in a user's codebase while still preventing PII from being exposed.\n\nHowever exceptions can occur by passing invalid options to the redactor, whether that's via the constructor, or via a redaction method.\n\n## No external dependencies\n\nKeeps project light, easier to maintain, easier to get approved by having Microsoft-only packages for less supply chain issues. Read more from Microsoft via [Best practices for a secure software supply chain](https://learn.microsoft.com/en-us/nuget/concepts/security-best-practices).\n\n## Microsoft.Extensions.Compliance.Redaction\n\nZeroRedact can be integrated into [Microsoft.Extensions.Compliance.Redaction](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.compliance.redaction) to provide full and partial redacting. \n\nSee [Compliance.Redaction-with-ZeroRedact](https://github.com/nikouu/Compliance.Redaction-with-ZeroRedact) for an example project.\n\n## Performance\n\n### Benchmarks\n\nSee the [benchmarks](https://nikouu.github.io/ZeroRedact/benchmarks/index.html) section of the documentation. Or view the [raw data](benchmarks).\n\n## Contributing\n\nCurrently not looking for contributions, however issues for problems or feature suggestions are welcome for consideration.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikouu%2Fzeroredact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikouu%2Fzeroredact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikouu%2Fzeroredact/lists"}