FGV.Lib.Security
1.0.0
dotnet add package FGV.Lib.Security --version 1.0.0
NuGet\Install-Package FGV.Lib.Security -Version 1.0.0
<PackageReference Include="FGV.Lib.Security" Version="1.0.0" />
<PackageVersion Include="FGV.Lib.Security" Version="1.0.0" />
<PackageReference Include="FGV.Lib.Security" />
paket add FGV.Lib.Security --version 1.0.0
#r "nuget: FGV.Lib.Security, 1.0.0"
#:package FGV.Lib.Security@1.0.0
#addin nuget:?package=FGV.Lib.Security&version=1.0.0
#tool nuget:?package=FGV.Lib.Security&version=1.0.0
FGV.Lib.Security
FGV.Lib.Security is a .NET library that provides security-related functionality to simplify the implementation of authentication and encryption in your applications. The library offers JWT (JSON Web Token) authentication helpers and encryption/decryption utilities.
Features
JWT Authentication
Token generation with customizable claims
JWT configuration for ASP.NET Core applications
Token validation setup
Cryptography
Encryption and decryption using AES (RijndaelManaged)
MD5 hashing specifically designed for medical residency platforms
Requirements
- .NET 7.0 or higher
- Dependencies:
- Microsoft.AspNetCore.Authentication.JwtBearer
- Microsoft.Extensions.Configuration
- Microsoft.Extensions.DependencyInjection
- System.IdentityModel.Tokens.Jwt
Installation
NuGet Package Manager
Install-Package FGV.Lib.Security
.NET CLI
dotnet add package FGV.Lib.Security
Usage
JWT Authentication Setup
Configure JWT authentication in your ASP.NET Core application:
using FGV.Lib.Security.Authentication;
using Microsoft.Extensions.DependencyInjection;
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Add JWT authentication
services.AddJwtSecurity(Configuration);
// Other service configurations...
}
}
Make sure your appsettings.json
includes the JWT configuration:
{
"Jwt": {
"Key": "your-secret-key-here",
"Issuer": "your-issuer",
"Audience": "your-audience",
"Expiration": 60
}
}
Generating JWT Tokens
using FGV.Lib.Security.Authentication;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
// Get the JWT options (typically via dependency injection)
var jwtOptions = serviceProvider.GetRequiredService<IOptions<JwtOptions>>().Value;
// User ID (GUID)
var userId = Guid.Parse("user-guid-here");
// User roles/profiles
var roles = new List<string> { "Admin", "User" };
// Generate the JWT token
string token = JwtSecurity.GerarJwt(userId, roles, jwtOptions);
Using Encryption and Decryption
using FGV.Lib.Security;
// Encrypt data
string originalText = "Sensitive information";
string encryptionKey = "your-encryption-key";
string encryptedText = Criptografia.Encrypt(originalText, encryptionKey);
// Decrypt data
string decryptedText = Criptografia.Decrypt(encryptedText, encryptionKey);
Creating MD5 Hash for Medical Residency
using FGV.Lib.Security;
string input = "data-to-hash";
string hashedValue = Criptografia.CriarHashMD5ParaRM(input);
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 7.0.13)
- Microsoft.IdentityModel.Tokens (>= 7.4.0)
- Newtonsoft.Json (>= 13.0.3)
- System.IdentityModel.Tokens.Jwt (>= 7.4.0)
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 | 858 | 5/29/2025 |