I had a similar problem, but I was using CryptoStream, FileStream and BinaryFormatter.
The following resolved the issue for me: prior to serializing the objects, I wrote a few characters into the stream, so I know where the beginning is. Then when I deserialize the objects I just need to read past these characters prior to beginning the deserialization.
The below examples are in c#, but you should get the idea of what I mean by writing a few characters into the stream.
//Below is a snippet from my serilization method
fs = new FileStream(mySavePath, FileMode.Create);
fs.Write(Encoding.ASCII.GetBytes("CRYPT"), 0, 5);
cs = new CryptoStream(fs, desCypher.CreateEncryptor(key, iv), CryptoStreamMode.Write);
bf = new BinaryFormatter();
bf.Context = new StreamingContext(StreamingContextStates.File);
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
bf.FilterLevel = TypeFilterLevel.Full;
bf.TypeFormat = FormatterTypeStyle.TypesAlways;
bf.Serialize(cs, myListToSave);
cs.FlushFinalBlock();
//Below is a snippet from my deserilization method
bf = new BinaryFormatter();
bf.Context = new StreamingContext(StreamingContextStates.File);
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
bf.FilterLevel = TypeFilterLevel.Full;
bf.TypeFormat = FormatterTypeStyle.TypesAlways;
fs = new FileStream(mySavePath, FileMode.Open, FileAccess.Read, FileShare.Read);
fs.Position = 5;
int length = (int)fs.Length;
byte[] encryptedBytes = new byte[fs.Length];
fs.Read(encryptedBytes, 0, length - 5);
fs.Position = 5;
cs = new CryptoStream(fs, decryptor, CryptoStreamMode.Read);
tempList = (myInfoList)bf.Deserialize((Stream)cs);