def read(length = nil, outbuf = nil)
      data             = outbuf.to_s.clear
      remaining_length = length

      until remaining_length == 0 || eof?
        read_block(remaining_length) if @read_buffer.empty?

        if remaining_length && remaining_length < @read_buffer.length
          data << @read_buffer.slice!(0, remaining_length)
        else
          data << @read_buffer
          @read_buffer.clear
        end

        remaining_length = length - data.length if length
      end

      @pos += data.length
      data unless data.empty? && length && length.positive?
    end
def read(length = nil, outbuf = nil)
      data             = outbuf.to_s.clear
      remaining_length = length

      until remaining_length == 0 || eof?
        read_block(remaining_length) if @read_buffer.empty?

        if remaining_length && remaining_length < @read_buffer.length
          data << @read_buffer.slice!(0, remaining_length)
        else
          data << @read_buffer
          @read_buffer.clear
        end

        remaining_length = length - data.length if length
      end

      @pos += data.length
      data unless data.empty? && length && length.positive?
    end
Read from the stream and return the decrypted data
 See IOS#read

 Reads at most length bytes from the I/O stream, or to the end of file if
 length is omitted or is nil. length must be a non-negative integer or nil.

 At end of file, it returns nil if no more data is available, or the last
 remaining bytes