Enum EncryptionAlgorithm
- Namespace
- Nucs.JsonSettings
- Assembly
- Nucs.JsonSettings.dll
Selects the symmetric algorithm EncryptionModule
uses. Every algorithm is provided by the .NET base class library
(System.Security.Cryptography); no third-party crypto is involved.
public enum EncryptionAlgorithm
Fields
AesCbc = 0AES in CBC mode with PKCS7 padding (unauthenticated). Layout:
IV(16) || ciphertext. This is the default and is byte-for-byte compatible with every version of this library.AesCbcHmac = 1AES-CBC with an HMAC-SHA256 tag in Encrypt-then-MAC order (authenticated). Layout:
IV(16) || ciphertext || HMAC(32). Available on every target framework.AesGcm = 2AES-GCM authenticated encryption (AEAD). Layout:
nonce(12) || ciphertext || tag(16). Requires .NET 6.0 or later.AesCcm = 3AES-CCM authenticated encryption (AEAD). Layout:
nonce(12) || ciphertext || tag(16). Requires .NET 6.0 or later and OS support for CCM.ChaCha20Poly1305 = 4ChaCha20-Poly1305 authenticated encryption (AEAD). Uses a fixed 256-bit key regardless of KeySize. Layout:
nonce(12) || ciphertext || tag(16). Requires .NET 6.0 or later and OS support for ChaCha20-Poly1305.
Remarks
The default is AesCbc - the historical format this library has always written, so files produced by any earlier version stay readable and nothing about the on-disk bytes changes for callers who do not opt into another algorithm.
The authenticated algorithms below (everything except AesCbc) verify an authentication tag when decrypting, so a wrong key or a tampered file fails with a real integrity error rather than the best-effort UTF-8 heuristic the unauthenticated AesCbc path relies on.
AEAD ciphers (AesGcm, AesCcm, ChaCha20Poly1305) are only present in
the BCL on .NET 6.0 and later, so those members do not exist when the library is built
for netstandard2.0 or net48; those targets offer AesCbc and
AesCbcHmac only.
There is no algorithm marker in the file. As with the password and key size, decrypting requires configuring the same algorithm the file was written with.