@Override public OutputStream createEncryptionStream(OutputStream out) { if (!initialized) { reset(); } try { return new CryptoOutputStream(cipherMode, properties, out, key, new IvParameterSpec(iv)); } catch (IOException e) { throw new RuntimeException(e); } }
private void encryptMore() throws IOException { byteRawChannel.reset(); if (isByteBuf) { int copied = byteRawChannel.write(buf.nioBuffer()); buf.skipBytes(copied); } else { region.transferTo(byteRawChannel, region.transferred()); } cos.write(byteRawChannel.getData(), 0, byteRawChannel.length()); cos.flush(); currentEncrypted = ByteBuffer.wrap(byteEncChannel.getData(), 0, byteEncChannel.length()); }
/** * Overrides the {@link java.io.OutputStream#write(byte[])}. Writes the * specified byte to this output stream. * * @param b the data. * @throws IOException if an I/O error occurs. */ @Override public void write(int b) throws IOException { oneByteBuf[0] = (byte) (b & 0xff); write(oneByteBuf, 0, oneByteBuf.length); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { try { cos.close(); } finally { super.close(ctx, promise); } } }
/** * Overrides the {@link OutputStream#flush()}. To flush, we need to encrypt * the data in the buffer and write to the underlying stream, then do the * flush. * * @throws IOException if an I/O error occurs. */ @Override public void flush() throws IOException { checkStream(); encrypt(); output.flush(); super.flush(); }
private void encryptMore() throws IOException { byteRawChannel.reset(); if (isByteBuf) { int copied = byteRawChannel.write(buf.nioBuffer()); buf.skipBytes(copied); } else { region.transferTo(byteRawChannel, region.transfered()); } cos.write(byteRawChannel.getData(), 0, byteRawChannel.length()); cos.flush(); currentEncrypted = ByteBuffer.wrap(byteEncChannel.getData(), 0, byteEncChannel.length()); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { try { cos.close(); } finally { super.close(ctx, promise); } } }
checkStream(); if (b == null) { throw new NullPointerException(); off += remaining; len -= remaining; encrypt();
private CryptoOutputStream createOutputStream(WritableByteChannel ch) throws IOException { return new CryptoOutputStream(cipher, conf, ch, key, new IvParameterSpec(outIv)); }
private void encryptMore() throws IOException { byteRawChannel.reset(); if (isByteBuf) { int copied = byteRawChannel.write(buf.nioBuffer()); buf.skipBytes(copied); } else { region.transferTo(byteRawChannel, region.transferred()); } cos.write(byteRawChannel.getData(), 0, byteRawChannel.length()); cos.flush(); currentEncrypted = ByteBuffer.wrap(byteEncChannel.getData(), 0, byteEncChannel.length()); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { try { cos.close(); } finally { super.close(ctx, promise); } } }
checkStream(); final int len = src.remaining(); int remaining = len; encrypt();
private CryptoOutputStream createOutputStream(WritableByteChannel ch) throws IOException { return new CryptoOutputStream(cipher, conf, ch, key, new IvParameterSpec(outIv)); }
private CryptoOutputStream createOutputStream(WritableByteChannel ch) throws IOException { return new CryptoOutputStream(cipher, conf, ch, key, new IvParameterSpec(outIv)); }
@Override public OutputStream createEncryptionStream(OutputStream out) { if (!initialized) { reset(); } try { return new CryptoOutputStream(cipherMode, properties, out, key, new IvParameterSpec(iv)); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public OutputStream createEncryptionStream(OutputStream out) { if (!initialized) { reset(); } try { return new CryptoOutputStream(cipherMode, properties, out, key, new IvParameterSpec(iv)); } catch (IOException e) { throw new RuntimeException(e); } }