A modern, professional security library for .NET, providing robust and easy-to-use services for AES-256 encryption and BCrypt password hashing. Designed for dependency injection and testability.
$ dotnet add package YojigenPoint.SecurityYojigenPoint.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.
IPasswordHasher, IEncryptionService) for easy integration into modern .NET applications using DI containers.This library is distributed as a NuGet package. You can add it to your project using the .NET CLI:
dotnet add package YojigenPoint.Security
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));
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 ...
}
}
This project is licensed under the MIT License. See the LICENSE.md file for details.