This allows us to make them private (rather than internal) and the type
as a whole is immutable.
It does mean we need to convert the key to an IntArray every time we use
it now. However, I hope that the JVM will be smart enough to inline the
toIntArray() method and also smart enough to realise it doesn't escape,
allowing it to allocate it on the stack rather than the heap.
This commit also adds methods for converting XteaKeys to hex, and
converting from hex/integer arrays to an XteaKey object.
Signed-off-by: Graham <gpe@openrs2.dev>
Unfortunately we can't use the compiler to guarantee k isn't changed,
though making it internal will help. When the JVM (and Kotlin) get value
types, we might be able to improve on this (e.g. by making it an inline
class of four integers).
Signed-off-by: Graham <gpe@openrs2.dev>
This commit updates the tests to ensure all combinations of 0-7 bytes of
leading/trailing blocks of unencrypted bytes work correctly with all
test vectors.
Signed-off-by: Graham <gpe@openrs2.dev>