Skip to content

C# lib to encrypt and decrypt data with symmetric/asymmetric algorithms

License

Notifications You must be signed in to change notification settings

nagilum/cryptocsharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Cryptography

A tiny C# library for encrypting and decrypting data using both symmetric (AES) and asymmetric (RSA) algorithms.

Symmetric (AES)

Symmetric encryption is best suited for small amounts of data.

// Set the passphrase.
const string passphrase = "This is a passphrase";

// Encrypt.
var encrypted = Cryptography.AES.Encrypt(
	"This is some text to encrypt",
	passphrase);

// Decrypt.
var decrypted = Cryptography.AES.Decrypt(
	encrypted,
	passphrase);

Asymmetric (RSA)

Asymmetric encryption is best suited for large amounts of data. With public/private key encryption you can also switch the keys if you wanted, encrypting with the private key and decrypting with the public key.

// Generate keys.
Cryptography.RSA.GenerateKeys(
	out var privateKey,
	out var publicKey,
	keySize: 2048); // The keySize is optional and defaults to 2048.

var encrypted = Cryptography.RSA.Encrypt(
	"... this is a large dataset ...",
	publicKey);

var decrypted = Cryptography.RSA.Decrypt(
	encrypted,
	privateKey);

About

C# lib to encrypt and decrypt data with symmetric/asymmetric algorithms

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages