gnu.crypto.pki

Class Util

public final class Util extends Object

A collection of useful class methods.

Author: Casey Marshall (rsdio@metastatic.org)

Field Summary
static StringHEX
Method Summary
static StringformatInt(int i, int radix, int len)
Format an integer into the specified radix, zero-filled.
static StringhexDump(byte[] buf, int off, int len, String prefix)
Create a representation of the given byte array similar to the output of `hexdump -C', which is

OFFSET  SIXTEEN-BYTES-IN-HEX  PRINTABLE-BYTES

The printable bytes show up as-is if they are printable and not a newline character, otherwise showing as '.'.

static StringhexDump(byte[] buf, String prefix)
static byte[]toByteArray(String hex)
Convert a hexadecimal string into its byte representation.
static StringtoHexString(byte[] buf, int off, int len)
Convert a byte array to a hexadecimal string, as though it were a big-endian arbitrarily-sized integer.
static StringtoHexString(byte[] buf)
static StringtoHexString(byte[] buf, int off, int len, char sep)
Convert a byte array to a hexadecimal string, separating octets with the given character.
static StringtoHexString(byte[] buf, char sep)

Field Detail

HEX

public static final String HEX

Method Detail

formatInt

public static String formatInt(int i, int radix, int len)
Format an integer into the specified radix, zero-filled.

Parameters: i The integer to format. radix The radix to encode to. len The target length of the string. The string is zero-padded to this length, but may be longer.

Returns: The formatted integer.

hexDump

public static String hexDump(byte[] buf, int off, int len, String prefix)
Create a representation of the given byte array similar to the output of `hexdump -C', which is

OFFSET  SIXTEEN-BYTES-IN-HEX  PRINTABLE-BYTES

The printable bytes show up as-is if they are printable and not a newline character, otherwise showing as '.'.

Parameters: buf The bytes to format. off The offset to start at. len The number of bytes to encode.

Returns: The formatted string.

hexDump

public static String hexDump(byte[] buf, String prefix)
See (byte[],int,int).

toByteArray

public static byte[] toByteArray(String hex)
Convert a hexadecimal string into its byte representation.

Parameters: hex The hexadecimal string.

Returns: The converted bytes.

toHexString

public static String toHexString(byte[] buf, int off, int len)
Convert a byte array to a hexadecimal string, as though it were a big-endian arbitrarily-sized integer.

Parameters: buf The bytes to format. off The offset to start at. len The number of bytes to format.

Returns: A hexadecimal representation of the specified bytes.

toHexString

public static String toHexString(byte[] buf)
See (byte[],int,int).

toHexString

public static String toHexString(byte[] buf, int off, int len, char sep)
Convert a byte array to a hexadecimal string, separating octets with the given character.

Parameters: buf The bytes to format. off The offset to start at. len The number of bytes to format. sep The character to insert between octets.

Returns: A hexadecimal representation of the specified bytes.

toHexString

public static String toHexString(byte[] buf, char sep)
See (byte[],int,int,char).
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.