YojigenPoint.Security
1.0.1
dotnet add package YojigenPoint.Security --version 1.0.1
NuGet\Install-Package YojigenPoint.Security -Version 1.0.1
<PackageReference Include="YojigenPoint.Security" Version="1.0.1" />
<PackageVersion Include="YojigenPoint.Security" Version="1.0.1" />
<PackageReference Include="YojigenPoint.Security" />
paket add YojigenPoint.Security --version 1.0.1
#r "nuget: YojigenPoint.Security, 1.0.1"
#:package YojigenPoint.Security@1.0.1
#addin nuget:?package=YojigenPoint.Security&version=1.0.1
#tool nuget:?package=YojigenPoint.Security&version=1.0.1
YojigenPoint.Security
YojigenPoint.Security is a modern, professional security library for .NET, providing robust and easy-to-use services for common cryptographic operations. It is designed with a focus on security best practices, performance, and testability.
This library abstracts away complex cryptographic implementations behind simple interfaces, allowing developers to secure their applications without needing to be security experts.
Features
- Password Hashing: A service-based implementation of the industry-standard BCrypt algorithm for securely hashing and verifying passwords.
- Symmetric Encryption: A robust implementation of AES-256 encryption. It correctly uses a PBKDF2-derived key, a random salt, and a random IV for every encryption operation, following modern security best practices.
- Dependency Injection Ready: All services are exposed via interfaces (
IPasswordHasher
,IEncryptionService
) for easy integration into modern .NET applications using DI containers.
Installation
This library is distributed as a NuGet package. You can add it to your project using the .NET CLI:
dotnet add package YojigenPoint.Security
Usage
1. Registering the Services
In your Program.cs or startup configuration, register the services with your DI container.
using YojigenPoint.Security.Abstractions;
using YojigenPoint.Security.Services;
// ...
// The Password Hasher is stateless, so it can be a Singleton.
builder.Services.AddSingleton<IPasswordHasher, BCryptPasswordHasher>();
// The Encryption Service requires a master key, which should be loaded from a secure configuration source.
var encryptionKey = builder.Configuration["EncryptionMasterKey"];
builder.Services.AddSingleton<IEncryptionService>(new AesEncryptionService(encryptionKey));
2. Using the Services in Your Application
Inject the interfaces into your classes via the constructor.
public class MyUserService
{
private readonly IPasswordHasher _passwordHasher;
private readonly IEncryptionService _encryptionService;
public MyUserService(IPasswordHasher passwordHasher, IEncryptionService encryptionService)
{
_passwordHasher = passwordHasher;
_encryptionService = encryptionService;
}
public void RegisterUser(string password, string personalData)
{
// Hash the password for storage
string passwordHash = _passwordHasher.Hash(password);
// Encrypt sensitive data
string encryptedData = _encryptionService.Encrypt(personalData);
// ... save to database ...
}
}
License
This project is licensed under the MIT License. See the LICENSE.md file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- BCrypt.Net-Next (>= 4.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Bug fixes: corrected a critical bug. This fix ensures the interface is correctly exposed and can be referenced by consuming projects.