/** * {@inheritDoc} */ protected void engineUpdate(byte b) { int pos = (int) (msgLength % BYTE_BLOCK_LENGTH); buffer[pos] = b; msgLength++; // If buffer contains enough data then process it. if (pos == (BYTE_BLOCK_LENGTH - 1)) { process(buffer, 0); } }
/** * {@inheritDoc} */ protected void engineUpdate(byte[] b, int offset, int len) { int pos = (int) (msgLength % BYTE_BLOCK_LENGTH); int nbOfCharsToFillBuf = BYTE_BLOCK_LENGTH - pos; int blkStart = 0; msgLength += len; // Process each full block if (len >= nbOfCharsToFillBuf) { System.arraycopy(b, offset, buffer, pos, nbOfCharsToFillBuf); process(buffer, 0); for (blkStart = nbOfCharsToFillBuf; blkStart + BYTE_BLOCK_LENGTH - 1 < len; blkStart += BYTE_BLOCK_LENGTH) { process(b, offset + blkStart); } pos = 0; } // Fill buffer with the remaining data if (blkStart < len) { System.arraycopy(b, offset + blkStart, buffer, pos, len - blkStart); } }