using System.Security.Cryptography;
public static void Main()
RijndaelManaged alg = new RijndaelManaged();
var encodedString = EncodeString("Hello, Dev!", alg.Key, alg.IV);
Console.WriteLine(encodedString);
static string EncodeString(string text, byte[] key, byte[] iv) {
RijndaelManaged alg = new RijndaelManaged();
var encryptor = alg.CreateEncryptor(key, iv);
using (var s = new MemoryStream())
using (var cs = new CryptoStream(s, encryptor, CryptoStreamMode.Write))
cs.Write(Encoding.UTF8.GetBytes(text));
return Convert.ToBase64String(s.ToArray());