AesCipherDataSink
@UnstableApi
public final class AesCipherDataSink implements DataSink
A wrapping DataSink that encrypts the data being consumed.
Summary
Public constructors |
|---|
AesCipherDataSink(byte[] secretKey, DataSink wrappedDataSink)Create an instance whose |
AesCipherDataSink(Create an instance whose |
Public methods |
|
|---|---|
void |
close()Closes the sink. |
void |
Opens the sink to consume the specified data. |
void |
write(byte[] buffer, int offset, int length)Consumes the provided data. |
Public constructors
AesCipherDataSink
public AesCipherDataSink(byte[] secretKey, DataSink wrappedDataSink)
Create an instance whose 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.
AesCipherDataSink
public AesCipherDataSink(
byte[] secretKey,
DataSink wrappedDataSink,
@Nullable byte[] scratch
)
Create an instance whose write methods are free of side effects. Use this constructor when the input data arrays are required to remain unchanged.
| Parameters | |
|---|---|
byte[] secretKey |
The key data. |
DataSink wrappedDataSink |
The wrapped |
@Nullable byte[] scratch |
Scratch space. Data is encrypted into this array before being written to the wrapped |
Public methods
close
public void close()
Closes the sink.
Note: This method must be called even if the corresponding call to open threw an IOException. See open for more details.
| Throws | |
|---|---|
java.io.IOException |
If an error occurs closing the sink. |
open
public void open(DataSpec dataSpec)
Opens the sink to consume the specified data.
Note: If an IOException is thrown, callers must still call close to ensure that any partial effects of the invocation are cleaned up.
| Parameters | |
|---|---|
DataSpec dataSpec |
Defines the data to be consumed. |
| Throws | |
|---|---|
java.io.IOException |
If an error occurs opening the sink. |
write
public void write(byte[] buffer, int offset, int length)
Consumes the provided data.
| Parameters | |
|---|---|
byte[] buffer |
The buffer from which data should be consumed. |
int offset |
The offset of the data to consume in |
int length |
The length of the data to consume, in bytes. |
| Throws | |
|---|---|
java.io.IOException |
If an error occurs writing to the sink. |