using (var aes = Aes.Create()) { aes.Key = keyBytes; aes.IV = iv; var encryptor = aes.CreateEncryptor(); byte[] encryptedBytes; using (var ms = new MemoryStream()) { using (var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) { using (var sw = new StreamWriter(cs)) { // encrypt the string sw.Write(plainText); } encryptedBytes = ms.ToArray(); } } string encryptedText = Convert.ToBase64String(encryptedBytes); }In this example, we are creating a new instance of Aes and setting the Key and IV properties. Then, we create an ICryptoTransform object and use it to encrypt a string inside a CryptoStream, which writes the encrypted data to a memory stream. Finally, we convert the encrypted bytes to a Base64 encoded string. The package for this library is System.Security.Cryptography.