Top Description Fields Constructors Methods
org.bouncycastle.util.encoders

public Class Hex

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream, org.bouncycastle.util.Strings

Utility class for converting hex data to bytes and back again.

Field Summary

Modifier and TypeField and Description
private static final HexEncoder

Constructor Summary

AccessConstructor and Description
public
Hex()

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

a byte array representing the decoded data.
decode
(byte[] data)

decode the Hex encoded input data.

public static byte[]

Returns:

a byte array representing the decoded data.
decode
(String data)

decode the Hex encoded String data - whitespace will be ignored.

public static int

Returns:

the number of bytes produced.
decode
(String data, OutputStream out)

decode the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.

public static byte[]

Returns:

a byte array representing the decoded data.
decodeStrict
(String str)

Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

public static byte[]

Returns:

a byte array representing the decoded data.
decodeStrict
(String str, int off, int len)

Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

public static byte[]

Returns:

a byte array containing the Hex encoded data.
encode
(byte[] data)

encode the input data producing a Hex encoded byte array.

public static byte[]

Returns:

a byte array containing the Hex encoded data.
encode
(byte[] data, int off, int length)

encode the input data producing a Hex encoded byte array.

public static int

Returns:

the number of bytes produced.
encode
(byte[] data, OutputStream out)

Hex encode the byte data writing it to the given output stream.

public static int

Returns:

the number of bytes produced.
encode
(byte[] data, int off, int length, OutputStream out)

Hex encode the byte data writing it to the given output stream.

public static String
toHexString(byte[] data)

public static String
toHexString(byte[] data, int off, int length)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

encoderback to summary
private static final HexEncoder encoder

Constructor Detail

Hexback to summary
public Hex()

Method Detail

decodeback to summary
public static byte[] decode(byte[] data)

decode the Hex encoded input data. It is assumed the input data is valid.

Returns:byte[]

a byte array representing the decoded data.

decodeback to summary
public static byte[] decode(String data)

decode the Hex encoded String data - whitespace will be ignored.

Returns:byte[]

a byte array representing the decoded data.

decodeback to summary
public static int decode(String data, OutputStream out) throws IOException

decode the Hex encoded String data writing it to the given output stream, whitespace characters will be ignored.

Returns:int

the number of bytes produced.

decodeStrictback to summary
public static byte[] decodeStrict(String str)

Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

Returns:byte[]

a byte array representing the decoded data.

decodeStrictback to summary
public static byte[] decodeStrict(String str, int off, int len)

Decode the hexadecimal-encoded string strictly i.e. any non-hexadecimal characters will be considered an error.

Returns:byte[]

a byte array representing the decoded data.

encodeback to summary
public static byte[] encode(byte[] data)

encode the input data producing a Hex encoded byte array.

Returns:byte[]

a byte array containing the Hex encoded data.

encodeback to summary
public static byte[] encode(byte[] data, int off, int length)

encode the input data producing a Hex encoded byte array.

Returns:byte[]

a byte array containing the Hex encoded data.

encodeback to summary
public static int encode(byte[] data, OutputStream out) throws IOException

Hex encode the byte data writing it to the given output stream.

Returns:int

the number of bytes produced.

encodeback to summary
public static int encode(byte[] data, int off, int length, OutputStream out) throws IOException

Hex encode the byte data writing it to the given output stream.

Returns:int

the number of bytes produced.

toHexStringback to summary
public static String toHexString(byte[] data)
toHexStringback to summary
public static String toHexString(byte[] data, int off, int length)