XorInterceptor 1.0.0

dotnet add package XorInterceptor --version 1.0.0
                    
NuGet\Install-Package XorInterceptor -Version 1.0.0
                    
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="XorInterceptor" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XorInterceptor" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="XorInterceptor">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 XorInterceptor --version 1.0.0
                    
#r "nuget: XorInterceptor, 1.0.0"
                    
#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.
#:package XorInterceptor@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XorInterceptor&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=XorInterceptor&version=1.0.0
                    
Install as a Cake Tool

XorInterceptor

A .NET Interceptor which does a simple XOR encryption at compile time, without embedding the plaintext literal in your IL. It scans the syntax tree for calls named Xor with zero arguments. It retrieves the interceptable location from the compiler and it will emit the interceptor method, instead of the original call.

⚠️ This currently requires .NET 9

devenv_wzIwCFKn4b

Installation

NuGet

.NET CLI
dotnet add package XorInterceptor
Package Reference
<PackageReference Include="XorInterceptor" Version="1.0.*" />

Option B — Local project reference

  </PropertyGroup>
    
    <InterceptorsNamespaces>$(InterceptorsNamespaces);XorInterceptor</InterceptorsNamespaces>
    <XorBuildSeed>$([System.Guid]::NewGuid().GetHashCode())</XorBuildSeed>
  </PropertyGroup>

  <ItemGroup>
    <CompilerVisibleProperty Include="XorBuildSeed" />
    <ProjectReference Include="..\XorInterceptor\XorInterceptor.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
  </ItemGroup>

Usage

You can take a look at the console application included, however it is nothing more than:

using static XorInterceptor.XorEncryption;

var encryptedString = Xor( /*"Hello, World"*/);
Console.WriteLine(encryptedString);

Now each time you (re)build your project the encryption changes.

⚠️ This is of course very easy to undo, since both the encrypted data and the key are next to eachother. It is more a proof of concept. <img width="1100" height="900" alt="image" src="https://github.com/user-attachments/assets/731019b2-acd2-4f00-a2ce-e61d05bb33f1" />

References

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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 128 8/31/2025