public byte[] ReadBytes()
{
// Fetch the unencrypted length from the beginning of the stream
ushort length = this.ReadUInt16();
if (length == 0) return null;
// Create a buffer the size of the length and populate the buffer
byte[] buffer = new byte[length];
this.innerStream.Read(buffer, 0, length);
// Decrypt the buffer and return the results
try
{
byte[] cleartext = this.mycrypt.GetBytes(buffer, Cryptkeeper.Action.Decrypt);
return cleartext;
}
catch (System.Security.Cryptography.CryptographicException)
{
// The decryption process failed
return null;
}
catch (Exception ex)
{
throw ex;
}
}