Ozcorps.Security 1.0.0

dotnet add package Ozcorps.Security --version 1.0.0
                    
NuGet\Install-Package Ozcorps.Security -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="Ozcorps.Security" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ozcorps.Security" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Ozcorps.Security" />
                    
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 Ozcorps.Security --version 1.0.0
                    
#r "nuget: Ozcorps.Security, 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 Ozcorps.Security@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=Ozcorps.Security&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Ozcorps.Security&version=1.0.0
                    
Install as a Cake Tool

Ozcorps.Security

Ozcorps.Security is a security utility library for ASP.NET Core applications. It provides password hashing, symmetric/asymmetric encryption, and file encryption with a clean DI-friendly API.

Target Frameworks

  • net8.0 (compatible with net9.0 and net10.0)

Installation

dotnet add package Ozcorps.Security

What's Included

  • IPasswordHasher — Argon2id-based password hasher with pepper support
  • IEncryptor + RsaEncryptor — RSA asymmetric encryption
  • IEncryptor + TripleDesEncryptor — TripleDES legacy encryption (deprecated, backward compat only)
  • IFileEncryptor + FileEncryptor — AES-GCM file encryption with PBKDF2 key derivation

Password Hashing (Argon2id)

Register the hasher:

builder.Services.AddArgon2PasswordHasher();

Inject and use:

public class UserService(IPasswordHasher hasher)
{
    public string CreateHash(string password) => hasher.Hash(password);
    public bool CheckPassword(string password, string stored) => hasher.Verify(password, stored);
}

Configuration

{
  "Security": {
    "Argon2": {
      "Pepper": ""
    }
  }
}

Important: In production, set Pepper via an environment variable or a secrets manager — never commit it to source control.

# .NET User Secrets (development)
dotnet user-secrets set "Security:Argon2:Pepper" "your-secret-pepper"

# Environment variable (production)
Security__Argon2__Pepper=your-secret-pepper
Parameter Default OWASP 2023
Iterations 3
MemorySize 65536 (64 MB)
DegreeOfParallelism 1
SaltSize 16 bytes
HashSize 32 bytes

Hash Format

{base64-salt}:{base64-hash}

Each call produces a unique output because the salt is randomly generated per hash.

RSA Encryption

Generate a key pair (run once, store securely):

var keys = RsaEncryptor.GenerateKeys(); // keys[0] = public, keys[1] = private

Register:

builder.Services.AddRsaEncryptor();

Configuration:

{
  "Security": {
    "Rsa": {
      "Public": "base64-xml-public-key",
      "Private": "base64-xml-private-key"
    }
  }
}

Usage:

public class SecretService(IEncryptor encryptor)
{
    public string Protect(string value) => encryptor.Encrypt(value);
    public string Reveal(string value) => encryptor.Decrypt(value);
}

File Encryption (AES-GCM)

Register:

builder.Services.AddFileEncryptor();

Usage:

public class FileService(IFileEncryptor fileEncryptor)
{
    public void EncryptUpload(IFormFile file, string outputPath, string password)
        => fileEncryptor.Encrypt(file, outputPath, password);

    public string DecryptFile(string encryptedPath, string password)
        => fileEncryptor.Decrypt(encryptedPath, password); // returns output file path
}

Binary format: [32-byte salt][12-byte nonce][ciphertext][16-byte tag]

Key derivation: PBKDF2-SHA256, 100 000 iterations.

TripleDES (Deprecated)

TripleDES was deprecated by NIST in 2023. Provided for backward compatibility only — use RsaEncryptor or FileEncryptor instead.

#pragma warning disable CS0618
builder.Services.AddTripleDesEncryptor();
#pragma warning restore CS0618

Configuration:

{
  "Md5Key": "your-key"
}

Migration from Ozcorps.Core

The following types from Ozcorps.Core have been moved here and are [Obsolete] in Core:

Ozcorps.Core (obsolete) Ozcorps.Security
Ozcorps.Core.Encryptors.IEncryptor Ozcorps.Security.Abstractions.IEncryptor
Ozcorps.Core.Encryptors.IFileEncryptor Ozcorps.Security.Abstractions.IFileEncryptor
Ozcorps.Core.Encryptors.RsaEncryptor Ozcorps.Security.Encryptors.RsaEncryptor
Ozcorps.Core.Encryptors.Md5Encryptor Ozcorps.Security.Encryptors.TripleDesEncryptor (renamed)
Ozcorps.Core.Encryptors.FileEncryptor Ozcorps.Security.Encryptors.FileEncryptor

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 82 3/11/2026