/// <summary> /// Initializes a new instance of the <see cref="PodBinaryDataFile"/> class from the given stream. /// </summary> /// <param name="stream">The <see cref="Stream"/> from which the data will be loaded.</param> /// <param name="leaveOpen">true to leave the stream open after loading, false to close it.</param> public PodBinaryDataFile(Stream stream, bool leaveOpen) { // Create the settings for the cryptor PodCryptoTransformConfig cryptoConfig = new PodCryptoTransformConfig() { FileSize = (uint)stream.Length }; // Read the contents through the encrypting stream using (CryptoStream cryptoStream = new CryptoStream(stream, new PodCryptoTransform(cryptoConfig), CryptoStreamMode.Read)) using (BinaryReader reader = new BinaryReader(cryptoStream, Encoding.ASCII, leaveOpen)) { ReadHeader(reader); // Store the retrieved coder key CoderKey = cryptoConfig.CoderKey; ReadData(reader); } }
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="PodCryptoTransform"/> class with the specified initial /// configuration. /// </summary> /// <param name="encrypt">Determines whether to encrypt or decrypt.</param> /// <param name="previousDword">The previous uint with which is XORed.</param> internal PodCryptoTransform(PodCryptoTransformConfig config) { Config = config; }