/** * Write a number of bytes without encrypting. * * @param b the source buffer * @param off the offset * @param len the number of bytes to write */ protected void writeDirect(byte[] b, int off, int len) { write(b, off, len); }
initKey(salt); write(magic, 0, len); checkedWriting = true; } else {
protected void writeDirect(byte[] b, int off, int len) { super.write(b, off, len); pos += len; }
public void write(byte[] b, int off, int len) { if (buffer.length < b.length) { buffer = new byte[len]; } System.arraycopy(b, off, buffer, 0, len); xorInitVector(buffer, 0, len, pos); cipher.encrypt(buffer, 0, len); super.write(buffer, 0, len); pos += len; }
private void flushBuffer(DataBuffer buff) { buff.checkCapacity(1); buff.put((byte) 0); buff.fillAligned(); buff.putInt(0, buff.length() / Constants.FILE_BLOCK_SIZE); file.write(buff.getBytes(), 0, buff.length()); }
@Override public void write(byte[] buff, int off, int len) { if (len > 0) { page.reset(); if (compress != null) { if (off != 0 || len != buff.length) { byte[] b2 = new byte[len]; System.arraycopy(buff, off, b2, 0, len); buff = b2; off = 0; } int uncompressed = len; buff = compress.compress(buff, compressionAlgorithm); len = buff.length; page.putInt(len); page.putInt(uncompressed); page.put(buff, off, len); } else { page.putInt(len); page.put(buff, off, len); } page.fillAligned(); fileStorage.write(page.getBytes(), 0, page.length()); } }