TopSecret.ProtectedString
2.1.0
See the version list below for details.
dotnet add package TopSecret.ProtectedString --version 2.1.0
NuGet\Install-Package TopSecret.ProtectedString -Version 2.1.0
<PackageReference Include="TopSecret.ProtectedString" Version="2.1.0" />
<PackageVersion Include="TopSecret.ProtectedString" Version="2.1.0" />
<PackageReference Include="TopSecret.ProtectedString" />
paket add TopSecret.ProtectedString --version 2.1.0
#r "nuget: TopSecret.ProtectedString, 2.1.0"
#:package TopSecret.ProtectedString@2.1.0
#addin nuget:?package=TopSecret.ProtectedString&version=2.1.0
#tool nuget:?package=TopSecret.ProtectedString&version=2.1.0
TopSecret
A small suite of .NET packages for keeping secrets safe in memory. It exists because SecureString never got a cross-platform story — its encryption is Windows-only and Microsoft advises against it for new code — yet real applications still hold passwords, API tokens, and cryptographic key material in plain strings and arrays that any heap dump, swap file, crash report, or memory scan can read. With TopSecret, secrets live AES-GCM-256-encrypted under a per-process (optionally hardware-backed) key, plaintext surfaces only briefly inside escape-resistant span callbacks, and every scratch buffer is pinned, locked, and wiped on exit.
Packages
- TopSecret.ProtectedString — the core: a cross-platform
SecureStringreplacement for text secrets, with constant-time equality, Argon2id credential hashing (OWASP defaults), opt-in hardware-backed key wrapping (Apple Secure Enclave / Android Keystore built in), and a bundled Roslyn analyzer that flags plaintext escaping the access callbacks. - TopSecret.ProtectedBlob — multi-megabyte binary secrets (key stores, sealed assets, model shards): write-once, chunked AES-GCM-256, streamed chunk-at-a-time reads that fail closed on tampering.
- TopSecret.ProtectedString.WindowsTpm — opt-in Windows TPM 2.0 wrapping of the process master key.
- TopSecret.ProtectedString.LinuxTpm — the same for Linux TPM 2.0 (
/dev/tpmrm0). - TopSecret.ProtectedString.Configuration — binds
appsettings.json/IConfigurationvalues straight intoProtectedString, with no plaintextstringdetour.
Documentation & threat model · Live browser demo · Changelog · MIT
The threat model defends secrets at rest in memory (dumps, swap, scraping) — not an attacker already executing code inside your process. Read it before relying on any in-memory protection.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-browser1.0 is compatible. net10.0-ios was computed. net10.0-ios26.0 is compatible. net10.0-maccatalyst was computed. net10.0-maccatalyst26.0 is compatible. net10.0-macos was computed. net10.0-macos26.0 is compatible. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
-
net10.0-android36.0
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
-
net10.0-browser1.0
- BouncyCastle.Cryptography (>= 2.6.2)
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
-
net10.0-ios26.0
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
-
net10.0-maccatalyst26.0
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
-
net10.0-macos26.0
- TopSecret.Cryptography.Argon2 (>= 2.1.6)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on TopSecret.ProtectedString:
| Package | Downloads |
|---|---|
|
TopSecret.ProtectedString.Configuration
Optional companion to TopSecret.ProtectedString that binds ProtectedStringOptions from a Microsoft.Extensions.Configuration source (e.g. appsettings.json). Adds a single dependency the main package deliberately does not take. |
|
|
TopSecret.ProtectedString.LinuxTpm
Linux TPM 2.0 hardware-backed master-key protector for TopSecret.ProtectedString. References the main package and auto-registers via ModuleInitializer when loaded on Linux. Uses Microsoft.TSS to talk TPM 2.0 commands directly to /dev/tpmrm0 (RSA-2048 OAEP-SHA256). On non-Linux hosts the package is a no-op. |
|
|
TopSecret.ProtectedString.WindowsTpm
Windows TPM 2.0 hardware-backed master-key protector for TopSecret.ProtectedString. References the main package and auto-registers via ModuleInitializer when loaded on Windows. Uses NCrypt + Microsoft Platform Crypto Provider (RSA-2048 OAEP-SHA256). On non-Windows hosts the package is a no-op. |
|
|
TopSecret.ProtectedBlob
Multi-megabyte secret blobs for TopSecret.ProtectedString: byte-oriented, write-once, stored as chunked AES-GCM-256 ciphertext in ordinary memory with a per-blob key wrapped under the shared process master (including the optional hardware-backed tiers). Reads decrypt one chunk at a time through span callbacks or streaming sinks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
## [2.1.0](https://github.com/Alpaq92/TopSecret.ProtectedString/compare/v2.0.0...v2.1.0) (2026-07-05)
### Features
* **demo:** use the package icon as the WASM demo's favicon ([fdda87d](https://github.com/Alpaq92/TopSecret.ProtectedString/commit/fdda87dd748e0afabce270d0a013cbebb2051c3b))
### Bug Fixes
* **demo:** fix cursor homing and simplify the loading-dot animation ([ddbedef](https://github.com/Alpaq92/TopSecret.ProtectedString/commit/ddbedeff3787348ae4a03c50a741ffce2ad075f3))