Download the required library for the Ascii <-> Hex functions HERE.
ASCII -> Hex
Hex -> ASCII
Dec -> Hex
Hex -> Dec
ASCII -> Hex
- Code:
public static String toHex(String ascii)
{
return Hex.encodeHexString(text.getBytes());
}
Hex -> ASCII
- Code:
public static String toAscii(String hex) throws DecoderException
{
return new String(Hex.decodeHex(hex.toCharArray()));
}
Dec -> Hex
- Code:
public static String toHex(int decimal)
{
return Integer.toHexString(decimal);
}
Hex -> Dec
- Code:
public static int toDec(String hex)
{
return Integer.parseInt(hex, 16);
}