Skip to content

2.Rijndael Cryptography

Lucas Eschechola edited this page Dec 8, 2021 · 3 revisions

Here's an example of how to use the Rijndael encryption algorithm using the EscNet micro framework

OBS: The cryptographic key must be a minimum of 16 characters and a maximum of 32.


First configure your dependency in your Startup.cs

services.AddRijndaelCryptography("YOUR ENCRYPTION KEY");



Now receive your dependency via constructor.

private readonly IRijndaelCryptography _rijndaelCryptography;

public MyClass(IRijndaelCryptography rijndaelCryptography){
    _rijndaelCryptography = rijndaelCryptography;
}



To encrypt phrase use:

string encryptedPhrase = _rijndaelCryptography.Encrypt("phrase to be encrypted");



And to decrypt the phrase use

string decryptedPhrase = _rijndaelCryptography.Decrypt("phrase to be decrypted");




2021 ©


Clone this wiki locally