Package org.elasticsearch.core
Class CharArrays
java.lang.Object
org.elasticsearch.core.CharArrays
Helper class similar to Arrays to handle conversions for Char arrays
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
charsBeginsWith
(String prefix, char[] chars) Tests if a char[] contains a sequence of characters that match the prefix.static boolean
constantTimeEquals
(char[] a, char[] b) Constant time equality check of char arrays to avoid potential timing attacks.static boolean
constantTimeEquals
(String a, String b) Constant time equality check of strings to avoid potential timing attacks.static byte[]
toUtf8Bytes
(char[] chars) Encodes the provided char[] to a UTF-8 byte[].static char[]
utf8BytesToChars
(byte[] utf8Bytes) Decodes the provided byte[] to a UTF-8 char[].
-
Method Details
-
utf8BytesToChars
public static char[] utf8BytesToChars(byte[] utf8Bytes) Decodes the provided byte[] to a UTF-8 char[]. This is done while avoiding conversions to String. The provided byte[] is not modified by this method, so the caller needs to take care of clearing the value if it is sensitive. -
toUtf8Bytes
public static byte[] toUtf8Bytes(char[] chars) Encodes the provided char[] to a UTF-8 byte[]. This is done while avoiding conversions to String. The provided char[] is not modified by this method, so the caller needs to take care of clearing the value if it is sensitive. -
charsBeginsWith
Tests if a char[] contains a sequence of characters that match the prefix. This is likeString.startsWith(String)
but does not require conversion of the char[] to a string. -
constantTimeEquals
public static boolean constantTimeEquals(char[] a, char[] b) Constant time equality check of char arrays to avoid potential timing attacks. -
constantTimeEquals
Constant time equality check of strings to avoid potential timing attacks.
-