DataSink.Factory
Constructor and Description |
---|
AesCipherDataSink(byte[] secretKey,
DataSink wrappedDataSink)
Create an instance whose
write methods have the side effect of overwriting the input
data . |
AesCipherDataSink(byte[] secretKey,
DataSink wrappedDataSink,
byte[] scratch)
Create an instance whose
write methods are free of side effects. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sink.
|
void |
open(DataSpec dataSpec)
Opens the sink to consume the specified data.
|
void |
write(byte[] data,
int offset,
int length)
Consumes the provided data.
|
public AesCipherDataSink(byte[] secretKey, DataSink wrappedDataSink)
write
methods have the side effect of overwriting the input
data
. Use this constructor for maximum efficiency in the case that there is no
requirement for the input data arrays to remain unchanged.secretKey
- The key data.wrappedDataSink
- The wrapped DataSink
.public AesCipherDataSink(byte[] secretKey, DataSink wrappedDataSink, byte[] scratch)
write
methods are free of side effects. Use this constructor
when the input data arrays are required to remain unchanged.secretKey
- The key data.wrappedDataSink
- The wrapped DataSink
.scratch
- Scratch space. Data is decrypted into this array before being written to the
wrapped DataSink
. It should be of appropriate size for the expected writes. If a
write is larger than the size of this array the write will still succeed, but multiple
cipher calls will be required to complete the operation.public void open(DataSpec dataSpec) throws IOException
DataSink
open
in interface DataSink
dataSpec
- Defines the data to be consumed.IOException
- If an error occurs opening the sink.public void write(byte[] data, int offset, int length) throws IOException
DataSink
write
in interface DataSink
data
- The buffer from which data should be consumed.offset
- The offset of the data to consume in buffer
.length
- The length of the data to consume, in bytes.IOException
- If an error occurs writing to the sink.public void close() throws IOException
DataSink
close
in interface DataSink
IOException
- If an error occurs closing the sink.