Class CharArrays


  • public final class CharArrays
    extends Object
    Helper class similar to Arrays to handle conversions for Char arrays
    • Method Detail

      • 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

        public static boolean charsBeginsWith​(String prefix,
                                              char[] chars)
        Tests if a char[] contains a sequence of characters that match the prefix. This is like String.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

        public static boolean constantTimeEquals​(String a,
                                                 String b)
        Constant time equality check of strings to avoid potential timing attacks.