Можно использовать библиотеку или подсмотреть реализацию:
https://github.com/2Toad/Rijndael256
https://www.nuget.org/packages/Rijndael256.Core/3.2.5
Почитай главу 3 в книге:
Advanced ASP.NET Core 3 Security. Understanding Hacks, Attacks, and Vulnerabilities to Secure Your Website. Узнаешь о проблемах шифрования текста, к примеру и вообще увидишь исходники примеров, как надо. Книгу можно купить на Amazon для приложения для Windows, которое называется Kindle.
string password = "sKzvYk#1Pn33!YN"; // The password to encrypt the data with
string plaintext = "Top secret data"; // The string to encrypt
// Encrypt the string
string ciphertext = Rijndael.Encrypt(plaintext, password, KeySize.Aes256);
// Decrypt the string
plaintext = Rijndael.Decrypt(ciphertext, password, KeySize.Aes256);