public final class ConcatAlgorithm extends Object implements CombiningSplitting
Simple implementation of combine/split algorithm. It combines inputs consecutively (simple concatenation).
It implies that this algorithm needs to know length of first input if split(byte[]) will be used.
combine(byte[], byte[]), there is no need to provide the length of first input, so
you can use ConcatAlgorithm() constructor.combine(byte[], byte[]) and split(byte[]), you must provide expected
length of first input, so you should use ConcatAlgorithm(int) constructor.
Note that this class is immutable so when this first input length is once set, then all first inputs needs to have
this length, otherwise IllegalArgumentException may occur.
This algorithm is sufficient for most cases. It has usage for input and salt combination before hashing because only combine operation is used (split is not needed). It can be also used for IV and cipher text combine/split during CBC because first input (IV) has always fixed length equal to cipher block size.
On the other hand, if you need split(byte[]) and expect dynamic size of both inputs, you must create new instance
every time you want to combine and split.
SaltingAdapter,
GenericEncryptionAlgorithm| Constructor and Description |
|---|
ConcatAlgorithm()
Creates a new instance of combine algorithm.
|
ConcatAlgorithm(int input1Length)
Creates a new instance of combine algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
combine(byte[] input1,
byte[] input2)
Combines together two byte arrays.
|
byte[][] |
split(byte[] combined)
Splits input (that was combined earlier) back to original.
|
public ConcatAlgorithm()
combine(byte[], byte[]) inputs but not
split(byte[]).public ConcatAlgorithm(int input1Length)
combine(byte[], byte[]) and split(byte[]).
You as a client are responsible to provide first inputinput1Length - expected length of first inputspublic byte[] combine(byte[] input1,
byte[] input2)
Combiningpublic byte[][] split(byte[] combined)
SplittingCopyright © 2019. All rights reserved.