Question: I am doing a task using ASP.NET where a user must upload a file and I encrypted with an already done encryption algorithm. The properties of the file are: `ID`, `Name`, and `tags`. Now, before I have encrypted strings, like a name for example, however, I've never encrypted a file and have no clue about it. 

**What exactly do I have to encrypt?**

**Encryption algorithm:**

```
public static void HybridEncrypt(string publicKey, MemoryStream fileToEncrypt, string filenameOfTheOutputFile)
{
     var publicKeyPath = Path.Combine(Directory.GetCurrentDirectory(), "\\publickey.key");
     Rijndael myAlg = Rijndael.Create();
     myAlg.GenerateIV(); //this is another method how to generate the secret key and iv
     myAlg.GenerateKey();

     byte[] keyStream = myAlg.Key;
     byte[] IVstream = myAlg.Key;
     MemoryStream msFileDataEncrypted = SymmetricEncryptData(fileToEncrypt, keyStream, IVstream);

     MemoryStream keyStreamEncrypt = new MemoryStream(myAlg.Key);
     MemoryStream msEncryptedSecretKey = new Encryption().AsymmetricallyEncrypt(publicKeyPath, keyStreamEncrypt);

     MemoryStream IVStreamEncrypt = new MemoryStream(myAlg.IV);
     MemoryStream msEncryptedIV = new Encryption().AsymmetricallyEncrypt(publicKeyPath, IVStreamEncrypt);

     MemoryStream msAll = new MemoryStream();

     msEncryptedSecretKey.Position = 0;
     msEncryptedIV.Position = 0;
     msFileDataEncrypted.Position = 0;

     msEncryptedSecretKey.CopyTo(msAll);
     msEncryptedIV.CopyTo(msAll);
     msFileDataEncrypted.CopyTo(msAll);
     System.IO.File.WriteAllBytes(filenameOfTheOutputFile, msAll.ToArray());
}

```

Answer: 
There are 3 things you need to resolve

1. According to oleksa's comment, you need to correct from `byte[] IVstream = myAlg.Key;` to `byte[] IVstream = myAlg.IV;`
2. You should encrypt file by converting from `httppostedfilebase to memorystream c#` then pass as `fileToEncrypt` param instead of `Encoding.UTF32.GetBytes(stringvale)`
3. `ID, Name, and tags` just the information that you store in database, no need to encrypt it.
Most probably, your initial vector size is less than 16 bytes. You need to increase the initial vector size.