Package com.helger.base.string
Class StringHex
java.lang.Object
com.helger.base.string.StringHex
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetHexByte(char cHigh, char cLow) static chargetHexChar(int n) Get the matching hex digit as a lower case character.static chargetHexCharUpperCase(int n) Get the matching hex digit as an upper case character.static byte[]getHexDecoded(char[] aInput) static byte[]getHexDecoded(char[] aInput, int nOfs, int nLen) static byte[]getHexDecoded(String sInput) static StringgetHexEncoded(byte[] aInput) Convert a byte array to a hexadecimal encoded string.static StringgetHexEncoded(byte[] aInput, int nOfs, int nLen) Convert a byte array to a hexadecimal encoded string.static StringgetHexEncoded(String sInput, Charset aCharset) Convert a string to a byte array and than to a hexadecimal encoded string.static StringgetHexString(byte nValue) static StringgetHexString(int nValue) static StringgetHexString(long nValue) static StringgetHexString(short nValue) static StringgetHexStringLeadingZero(byte nValue, int nDigits) static StringgetHexStringLeadingZero(int nValue, int nDigits) static StringgetHexStringLeadingZero(long nValue, int nDigits) static StringgetHexStringLeadingZero(short nValue, int nDigits) static StringgetHexStringLeadingZero2(byte nValue) static intgetHexValue(char c) Get the decimal value of the passed hex character
-
Method Details
-
getHexChar
public static char getHexChar(int n) Get the matching hex digit as a lower case character.- Parameters:
n- The value to get the hex digit from. Must be between 0 and 15.- Returns:
- The hex character (one of 0-9 or a-f), or '\0' if the value could not be converted
-
getHexCharUpperCase
public static char getHexCharUpperCase(int n) Get the matching hex digit as an upper case character.- Parameters:
n- The value to get the hex digit from. Must be between 0 and 15.- Returns:
- The hex character (one of 0-9 or A-F), or '\0' if the value could not be converted
-
getHexEncoded
Convert a string to a byte array and than to a hexadecimal encoded string.- Parameters:
sInput- The source string. May not benull.aCharset- The charset to use. May not benull.- Returns:
- The String representation of the byte array of the string.
-
getHexEncoded
Convert a byte array to a hexadecimal encoded string.- Parameters:
aInput- The byte array to be converted to a String. May not benull.- Returns:
- The String representation of the byte array.
-
getHexEncoded
Convert a byte array to a hexadecimal encoded string.- Parameters:
aInput- The byte array to be converted to a String. May not benull.nOfs- Byte array offsetnLen- Number of bytes to encode- Returns:
- The String representation of the byte array.
-
getHexValue
@CheckForSigned public static int getHexValue(@Nonnegative char c) Get the decimal value of the passed hex character- Parameters:
c- The hex char to convert (0-9, a-f, A-F)- Returns:
- A value between 0 and 15, or -1 if the input character is not a hex char!
-
getHexByte
public static int getHexByte(@Nonnegative char cHigh, @Nonnegative char cLow) - Parameters:
cHigh- High hex partcLow- Low hex part- Returns:
- A value between 0 and 255, or -1 if any input character is not a hex char!
-
getHexDecoded
-
getHexDecoded
@Nonnull @ReturnsMutableCopy public static byte[] getHexDecoded(@Nonnull char[] aInput) -
getHexDecoded
@Nonnull @ReturnsMutableCopy public static byte[] getHexDecoded(@Nonnull char[] aInput, @Nonnegative int nOfs, @Nonnegative int nLen) -
getHexString
-
getHexStringLeadingZero
-
getHexStringLeadingZero2
-
getHexString
-
getHexStringLeadingZero
-
getHexString
-
getHexStringLeadingZero
-
getHexString
-
getHexStringLeadingZero
-