/// <summary> /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number /// of bytes written. /// </summary> /// <param name="buffer"> /// An array of bytes. This method copies <paramref name="count" /> bytes from /// <paramref name="buffer" /> to the current stream. /// </param> /// <param name="offset"> /// The zero-based byte offset in <paramref name="buffer" /> at which to begin copying bytes to the /// current stream. /// </param> /// <param name="count">The number of bytes to be written to the current stream.</param> public override void Write(byte[] buffer, int offset, int count) { ValidateSize(count); if (count == 0) { return; } //get the current sector var currentSector = CurrentSector; if (_encryptor == null) { _encryptor = _xts.CreateEncryptor(); } //encrypt the sector var transformedCount = _encryptor.TransformBlock(buffer, offset, count, _tempBuffer, 0, currentSector); //Console.WriteLine("Encrypting sector {0}", currentSector); //write it to the base stream base.Write(_tempBuffer, 0, transformedCount); }
public override void Write(byte[] buffer, int offset, int count) { ValidateSize(count); if (count != 0) { ulong currentSector = base.CurrentSector; if (_encryptor == null) { _encryptor = _xts.CreateEncryptor(); } int count2 = _encryptor.TransformBlock(buffer, offset, count, _tempBuffer, 0, currentSector); base.Write(_tempBuffer, 0, count2); } }