/// Method <c>Encrypt</c> encrypts the given plain text using the provided AES object.
/// </summary>
/// <param name="plainText">The plain text to encrypt.</param>
/// <param name="aes">The AES object to use for encryption.</param>
/// <returns>The encrypted text as a base64 string.</returns>
staticstringEncrypt(stringplainText,Aesaes){
usingMemoryStreammemoryStream=new();// Creates a new memory stream for writing data
usingCryptoStreamcryptoStream=new(memoryStream,aes.CreateEncryptor(),CryptoStreamMode.Write);// Creates a new CryptoStream using the given Aes object and the memory stream for writing data
usingStreamWriterstreamWriter=new(cryptoStream);// Creates a new StreamWriter using the above CryptoStream
streamWriter.Write(plainText);// Writes the plain text to the StreamWriter
cryptoStream.FlushFinalBlock();// Writes the final block of data to the CryptoStream and closes the stream
stringoutput=Convert.ToBase64String(memoryStream.ToArray());// Converts the contents of the memory stream to a byte array and returns the base64-encoded string representation of the array
returnoutput;// Returns the encrypted output as a base64 string
/// Method <c>Decrypt</c> decrypts the given encrypted text using the provided AES object.
/// </summary>
/// <param name="encryptedText">The encrypted text to decrypt, as a Base64 string.</param>
/// <param name="aes">The AES object to use for decryption.</param>
/// <returns>The decrypted string, in plain-text</returns>
staticstringDecrypt(stringencryptedText,Aesaes){
usingMemoryStreammemoryStream=new(Convert.FromBase64String(encryptedText));// Creates a new memory stream using the given encrypted text, converted from a base64 string to a byte array
usingCryptoStreamcryptoStream=new(memoryStream,aes.CreateDecryptor(),CryptoStreamMode.Read);// Creates a new CryptoStream using the given AES object and the memory stream for reading data
usingStreamReaderstreamReader=new(cryptoStream);// Creates a new StreamReader using the above CryptoStream
stringoutput=streamReader.ReadToEnd();// Reads the entire stream and returns the contents as a string
returnoutput;// Returns the decrypted output as a string