SkillAgentSearch skills...

SecureStringNAOT

Compile time string encryption with NativeAOT

Install / Use

/learn @ZeroLP/SecureStringNAOT
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

SecureStringNAOT

Compile time string encryption with NativeAOT

This example utilises the fact that the static constructors including static readonly fields are pre-interpreted at compile time when the ILC(NativeAOT compiler) translates the code into native code.

Limitation

As the strings are a reference-type that are allocated on the heap, they are ultimately baked statically into the compiled executable. Therefore, only stack allocated Span<char> can be encrypted. Any solution is welcomed via PR, however I have yet to find a viable solution as the issue tightly relates to how strings work in .NET.

Before Decryption

After Decryption

Related Skills

View on GitHub
GitHub Stars32
CategoryDevelopment
Updated2mo ago
Forks6

Languages

C#

Security Score

95/100

Audited on Jan 17, 2026

No findings