Librería de clases para encriptación y desencriptación utilizando AES, RSA y ECC.
$ dotnet add package DMS.SecurityPaquete Nuget: DMS.Security Autor: Fredy Fuentes Versión Actual: 1.0.0
DMS.Security Biblioteca de seguridad para .NET que implementa cifrado simétrico (AES) y asimétrico (RSA, ECC). Ideal para proteger datos sensibles, gestionar claves con expiración y garantizar integridad en comunicaciones.
using DMS.Security;
// Generar clave y vector de inicialización
var aes = new AesEncryption(out string key, out string iv);
// Encriptar texto
string encryptedText = aes.Encrypt("Hello, World!");
// Desencriptar texto
var aesWithExistingKey = new AesEncryption(key, iv);
string decryptedText = aesWithExistingKey.Decrypt(encryptedText);
Console.WriteLine($"Encrypted Text: {encryptedText}");
Console.WriteLine($"Decrypted Text: {decryptedText}");
// Output:
// Encrypted Text: <encrypted-text>
// Decrypted Text: Hello, World!
using DMS.Security;
// Generar clave pública y privada
var sender = RsaEncryption.GenerateKeys(out string senderPublicKey, out string senderPrivateKey);
var receiver = RsaEncryption.GenerateKeys(out string receiverPublicKey, out string receiverPrivateKey);
// Encriptar texto con clave pública del receptor
string encryptedText = sender.Encrypt("Hello, World!", receiverPublicKey);
// Desencriptar texto con clave privada del receptor
string decryptedText = receiver.Decrypt(encryptedText, receiverPrivateKey);
Console.WriteLine($"Encrypted Text: {encryptedText}");
Console.WriteLine($"Decrypted Text: {decryptedText}");
// Output:
// Encrypted Text: <encrypted-text>
// Decrypted Text: Hello, World!
using DMS.Security;
// Generar clave pública y privada
var sender = EccEncryption.GenerateKeys(out string senderPublicKey, out string senderPrivateKey);
var receiver = EccEncryption.GenerateKeys(out string receiverPublicKey, out string receiverPrivateKey);
// Encriptar texto con clave pública del receptor
string encryptedText = sender.Encrypt("Hello, World!", receiverPublicKey);
// Desencriptar texto con clave privada del receptor
string decryptedText = receiver.Decrypt(encryptedText, senderPublicKey);
Console.WriteLine($"Encrypted Text: {encryptedText}");
Console.WriteLine($"Decrypted Text: {decryptedText}");
// Output:
// Encrypted Text: <encrypted-text>
// Decrypted Text: Hello, World!Puedes instalar el paquete desde NuGet con:
dotnet add package DMS.Security| Clase | Descripción |
|---|---|
AesEncryption | Cifrado simétrico con auto-generación de claves. |
RsaEncryption | Cifrado asimétrico RSA estándar con claves XML. |
EccEncryption | Cifrado híbrido ECDH (derivación) + AES-GCM. |
Este proyecto se encuentra bajo la licencia Apache2-0.
Si deseas contribuir, revisa el archivo CONTRIBUTING.md para más detalles.
Para ver los cambios en cada versión, consulta el archivo CHANGELOG.md.