Package opencard.core.util
Class HexString
- java.lang.Object
-
- opencard.core.util.HexString
-
public class HexString extends java.lang.Object
Small utility class to hexify bytes and shorts.- Author:
- Michael Baentsch (mib@zurich.ibm.com), Dirk Husemann (hud@zurich.ibm.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String[]
hexChars
Auxillary string array.
-
Constructor Summary
Constructors Constructor Description HexString()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
dump(byte[] data)
Hex-dump a byte array (offset and printable ASCII included)static java.lang.String
dump(byte[] data, int offset, int len)
Hex-dump a byte array (offset and printable ASCII included)static java.lang.String
hexify(byte[] data)
Hexify a byte array.static java.lang.String
hexify(int val)
Hexify a byte value.static java.lang.String
hexifyShort(byte a, byte b)
Hexify short value encoded in two bytes.static java.lang.String
hexifyShort(int val)
Hexify a short value.static java.lang.String
hexifyShort(int a, int b)
Hexify short value encoded in two (int-encoded)bytes.static byte[]
parseHexString(java.lang.String byteString)
Parse bytes encoded as Hexadecimals into a byte array.static byte[]
parseLittleEndianHexString(java.lang.String byteString)
Parse string of Hexadecimals into a byte array suitable for unsigned BigInteger computations.
-
-
-
Method Detail
-
dump
public static java.lang.String dump(byte[] data)
Hex-dump a byte array (offset and printable ASCII included)- Parameters:
data
- Byte array to convert to HexString- Returns:
- HexString
-
dump
public static java.lang.String dump(byte[] data, int offset, int len)
Hex-dump a byte array (offset and printable ASCII included)- Parameters:
data
- Byte array to convert to HexStringoffset
- Start dump herelen
- Number of bytes to be dumped.- Returns:
- HexString
-
hexify
public static java.lang.String hexify(byte[] data)
Hexify a byte array.- Parameters:
data
- Byte array to convert to HexString- Returns:
- HexString
-
hexify
public static java.lang.String hexify(int val)
Hexify a byte value.- Parameters:
val
- Byte value to be displayed as a HexString.- Returns:
- HexString
-
hexifyShort
public static java.lang.String hexifyShort(byte a, byte b)
Hexify short value encoded in two bytes.- Parameters:
a
- High byte of short value to be hexifiedb
- Low byte of short value to be hexified- Returns:
- HexString
-
hexifyShort
public static java.lang.String hexifyShort(int val)
Hexify a short value.- Parameters:
val
- Short value to be displayed as a HexString.- Returns:
- HexString
-
hexifyShort
public static java.lang.String hexifyShort(int a, int b)
Hexify short value encoded in two (int-encoded)bytes.- Parameters:
a
- High byte of short value to be hexifiedb
- Low byte of short value to be hexified- Returns:
- HexString
-
parseHexString
public static byte[] parseHexString(java.lang.String byteString)
Parse bytes encoded as Hexadecimals into a byte array.- Parameters:
byteString
- String containing HexBytes.- Returns:
- byte array containing the parsed values of the given string.
-
parseLittleEndianHexString
public static byte[] parseLittleEndianHexString(java.lang.String byteString)
Parse string of Hexadecimals into a byte array suitable for unsigned BigInteger computations. Reverse the order of the parsed data on the fly (input data little endian).- Parameters:
byteString
- String containing HexBytes.- Returns:
- byte array containing the parsed values of the given string.
-
-