Skip to content

jay13makhija/Nuget-JHashEncryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

📦 JHashEncryption.Security

Secure your .NET microservices with RSA-OAEP-SHA256 encryption and Argon2id hashing — built for performance, reliability, and middleware integration.

Try Now

https://www.nuget.org/packages/JHashEncryption.Security


🔐 Overview

JHashEncryption.Security is a lightweight, production-ready NuGet package that provides:

  • ✅ RSA-OAEP-SHA256 encryption/decryption for secure payload handling
  • ✅ Argon2id password hashing for modern authentication flows
  • ✅ Plug-and-play middleware for automatic request/response encryption
  • ✅ Direct service injection for manual control in business logic

Built for .NET 10+, this package is ideal for developers building secure APIs, microservices, and cloud-native apps.


🚀 Installation

dotnet add package JHashEncryption.Security

⚙️ Setup

1. Register Services

builder.Services.AddJHashEncryption(publicKeyPem, privateKeyPem);

2. Enable Middleware

app.UseJHashEncryption();

You can use the middleware and/or inject services directly into your controllers or services.

🧪 Usage Examples

1. Dependency Injection (Ideal for microservices)

private readonly RsaOaepSha256Crypto _crypto;
private readonly Argon2Hasher _hasher;

public Class_Name(RsaOaepSha256Crypto crypto, Argon2Hasher hasher)
{
    _crypto = crypto;
    _hasher = hasher;
}

🔹 Encrypt/Decrypt Payloads

var encrypted = _crypto.Encrypt("sensitive data");
var decrypted = _crypto.Decrypt(encrypted);

🔹 Hash and Verify Passwords

var hash = _hasher.HashPassword("myPassword");
var isValid = _hasher.VerifyPassword("myPassword", hash);

2. Manual Usage (No DI)

🔹 Encrypt/Decrypt Payloads

var crypto = new RsaOaepSha256Crypto(publicKeyPem, privateKeyPem);
var encrypted = crypto.Encrypt("sensitive data");
var decrypted = crypto.Decrypt(encrypted);

🔹 Hash and Verify Passwords

var hasher = new Argon2Hasher();
var hash = hasher.HashPassword("myPassword");

🧰 API Surface

Service Description
RsaOaepSha256Crypto Encrypts and decrypts strings using RSA-OAEP padding with SHA-256
Argon2Hasher Hashes and verifies passwords using Argon2id
JHashEncryptionMiddleware ASP.NET Core middleware for automatic request/response encryption

🛡️ Why JHashEncryption?

  • 🔒 Modern cryptography: RSA-OAEP-SHA256 + Argon2id = secure by default
  • ⚡ Minimal overhead: optimized for performance in microservices
  • 🧩 Flexible architecture: use as middleware or inject directly
  • 🧠 Built by a systems thinker: designed for reliability, clarity, and maintainability

📄 License

MIT — free to use, modify, and distribute.