Reads the specified bytes of data from the underlying input stream and updates the hasher with
the bytes read.
430304
@Override

    public int read(byte[] bytes, int off, int len) throws IOException {
        int numOfBytesRead = in.read(bytes, off, len);
        if (numOfBytesRead != -1) {
            hasher.put(bytes, off, numOfBytesRead);
        }
        return numOfBytesRead;
    }
184860
static byte[] readAllBytes(InputStream stream) throws IOException {
    int bytesRead = 0;
    byte[] currentChunk = new byte[255];
    final List<byte[]> chunks = new ArrayList<byte[]>();
    while ((bytesRead = stream.read(currentChunk)) != -1) {
      chunks.add(copyOf(currentChunk, bytesRead));
    }

    if (chunks.size() <= 0) {
      throw new IOException("Stream did not contain any data. Please provide data to upload.");
    }

    int size = 0;
    for (byte[] chunk : chunks) {
      size += chunk.length;
    }

    final byte[] content = new byte[size];
    int position = 0;
    for (byte[] chunk : chunks) {
      arraycopy(chunk, 0, content, position, chunk.length);
      position += chunk.length;
    }
    return content;
  }
291469
def update(self, incoming_stream, seek=0, size=None, chunk_size=None,
               progress_callback=None):
        """"""
        fp = self.open(mode='r+b')
        try:
            fp.seek(seek)
            bytes_written, checksum = self._write_stream(
                incoming_stream, fp, chunk_size=chunk_size,
                size=size, progress_callback=progress_callback)
        finally:
            fp.close()

        return bytes_written, checksum
940535
public static byte[] hashTwice(byte[] input1, byte[] input2) {
        MessageDigest digest = newDigest();
        digest.update(input1);
        digest.update(input2);
        return digest.digest(digest.digest());
    }
760335
def update(self, data, length=None):
        
        if self.digest_finalized:
            raise DigestError("No updates allowed")
        if not isinstance(data, bintype):
            raise TypeError("A byte string is expected")
        if length is None:
            length = len(data)
        elif length > len(data):
            raise ValueError("Specified length is greater than length of data")
        result = libcrypto.EVP_DigestUpdate(self.ctx, c_char_p(data), length)
        if result != 1:
            raise DigestError("Unable to update digest")
116954
private void readInput() {
        if (buf.limit() == buf.capacity())
            makeSpace();

        // Prepare to receive data
        int p = buf.position();
        buf.position(buf.limit());
        buf.limit(buf.capacity());

        int n = 0;
        try {
            n = source.read(buf);
        } catch (IOException ioe) {
            lastException = ioe;
            n = -1;
        }

        if (n == -1) {
            sourceClosed = true;
            needInput = false;
        }

        if (n > 0)
            needInput = false;

        // Restore current position and limit for reading
        buf.limit(buf.position());
        buf.position(p);
        // Android-changed: The matcher implementation eagerly calls toString() so we'll have
        // to update its input whenever the buffer limit, position etc. changes.
        matcher.reset(buf);
    }
276417
public void update ( byte[] input, int offset, int len ) {
        if ( log.isTraceEnabled() ) {
            log.trace("update: " + this.updates + " " + offset + ":" + len);
            log.trace(Hexdump.toHexString(input, offset, Math.min(len, 256)));
        }
        if ( len == 0 ) {
            return; /* CRITICAL */
        }
        this.digest.update(input, offset, len);
        this.updates++;
    }
1276811
def hash_stream(fileobj, hasher=None, blocksize=65536):
    
    hasher = hasher or hashlib.sha1()
    buf = fileobj.read(blocksize)
    while buf:
        hasher.update(buf)
        buf = fileobj.read(blocksize)
    return hasher
259481
def _read_bytes(self, b):
        
        _LOGGER.debug("%d bytes requested from stream with content type: %s", b, self.content_type)
        if 0 <= b <= len(self.output_buffer) or self.__message_complete:
            _LOGGER.debug("No need to read from source stream or source stream closed")
            return

        if self.content_type == ContentType.FRAMED_DATA:
            _LOGGER.debug("Reading to framed body")
            self.output_buffer += self._read_bytes_to_framed_body(b)
        elif self.content_type == ContentType.NO_FRAMING:
            _LOGGER.debug("Reading to non-framed body")
            self.output_buffer += self._read_bytes_to_non_framed_body(b)
        else:
            raise NotSupportedError("Unsupported content type")

        # To maintain backwards compatibility, only enforce this if a CMM is provided by the caller.
        if self.config.key_provider is None and self.config.source_length is not None:
            # Enforce that if the caller provided a source length value, the total bytes encrypted
            # must not exceed that value.
            if self._bytes_encrypted > self.config.source_length:
                raise CustomMaximumValueExceeded(
                    "Bytes encrypted has exceeded stated source length estimate:\n{actual:d} > {estimated:d}".format(
                        actual=self._bytes_encrypted, estimated=self.config.source_length
                    )
                )
916873
def read_bytes(self, length) -> bytes:
        
        value = self.stream.read(length)
        return value
416823
def update_hash_from_str(hsh, str_input):
    
    byte_input = str(str_input).encode("UTF-8")
    hsh.update(byte_input)
75891
public static byte[] readbytes(InputStream input, int n) throws IOException {
		byte[] buffer = new byte[n];
		readbytes_into(input, buffer, 0, n);
		return buffer;
	}
1040655
final byte[] hmac(final byte[] input, final int offset, final int len) {
		hMac.update(input, offset, len);
		return hMac.doFinal();
	}
417671
private byte nextByte(ByteBuffer inputBuffer) throws IOException {
        getAtLeastBytes(inputBuffer, 1, ReadMode.ONLY_WHEN_EMPTY);
        return inputBuffer.get();
    }
748274
static byte[] readFully(DataInput stream, int len) throws IOException {
        if (len == 0) {
            return null;
        }

        byte[] data = new byte[len];
        stream.readFully(data);
        return data;
    }
222955
void readFrom(InputStream in) throws IOException {
		//TODO could optimize for aligned instances
		final int size = finish - start;
		final int length = (size + 7) >> 3;
		if (length == 0) return;
		int p = size & 7;
		final int q = finish - p;
		if (p != 0) performAdj(SET, q, (long) in.read(), p);
		p = q;
		while (p > start) {
			p -= 8;
			performAdj(SET, p, (long) in.read(), 8);
		}
	}
374894
public static void streamCopy(InputStream input, Writer output) throws IOException
	{
		if (input == null)
			throw new IllegalArgumentException("Must provide something to read from");
		if (output == null)
			throw new IllegalArgumentException("Must provide something to write to");

		streamCopy(new InputStreamReader(input), output);
	}