예제 #1
0
        /// <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 count bytes from buffer to the current stream. </param>
        /// <param name="offset">The byte offset in 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)
        {
            long base_offset = offset + _stream.Position;

            HfsXorCipher.XorBlockWithKey(buffer, _key, (int)base_offset);

            _stream.Write(buffer, offset, count);
        }
예제 #2
0
        /// <summary>
        /// Reads a sequence of bytes from the current CryptoStream into buffer,
        /// and advances the position within the stream by the number of bytes read.
        /// </summary>
        public override int Read(byte[] outBuffer, int offset, int count)
        {
            long base_offset = _base + offset + _stream.Position;

            _stream.Read(outBuffer, offset, count);

            HfsXorCipher.XorBlockWithKey(outBuffer, _key, (int)base_offset);

            return(count);
        }