Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
gnu.java.security.util.Util
Method Summary | |
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static byte[] |
|
static int |
|
static String |
|
static byte[] |
|
static byte[] | |
static byte[] |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static byte[] |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static String byteToString(int n)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits ofn
.
- Parameters:
n
- the byte value to convert.
- Returns:
- a string of 2 hex characters representing the input.
public static final String dump(BigInteger x)
Returns a hexadecimal dump of the trimmed bytes of aBigInteger
.
- Parameters:
x
- theBigInteger
to display.
- Returns:
- the string representation of the designated
BigInteger
.
public static String dumpString(byte[] data, int offset, int length, String m)
Dumps a byte array as a string, in a format that is easy to read for debugging. The stringm
is prepended to the start of each line.If
offset
andlength
are omitted, the whole array is used. Ifm
is omitted, nothing is prepended to each line.
- Parameters:
data
- the byte array to be dumped.offset
- the offset within data to start from.length
- the number of bytes to dump.m
- a string to be prepended to each line.
- Returns:
- a string containing the result.
public static final byte[] fromBase64(String str)
The inverse function of the above.Converts a string representing the encoding of some bytes in Base-64 to their original form.
- Parameters:
str
- the Base-64 encoded representation of some byte(s).
- Returns:
- the bytes represented by the
str
.
- Throws:
NumberFormatException
- ifstr
isnull
, orstr
contains an illegal Base-64 character.
- See Also:
toBase64(byte[])
public static int fromDigit(char c)
Returns a number from0
to15
corresponding to the designated hexadecimal digit.
- Parameters:
c
- a hexadecimal ASCII symbol.
public static final String toBase64(byte[] buffer)
Converts a designated byte array to a Base-64 representation, with the exceptions that (a) leading 0-byte(s) are ignored, and (b) the character '.' (dot) shall be used instead of "+' (plus).Used by SASL password file manipulation primitives.
- Parameters:
buffer
- an arbitrary sequence of bytes to represent in Base-64.
- Returns:
- unpadded (without the '=' character(s)) Base-64 representation of the input.
public static byte[] toBytesFromString(String s)
Returns a byte array from a string of hexadecimal digits.
- Parameters:
s
- a string of hexadecimal ASCII characters
- Returns:
- the decoded byte array from the input hexadecimal string.
public static byte[] toReversedBytesFromString(String s)
Returns a byte array from a string of hexadecimal digits, interpreting them as a large big-endian integer and returning it as a large little-endian integer.
- Parameters:
s
- a string of hexadecimal ASCII characters
- Returns:
- the decoded byte array from the input hexadecimal string.
public static String toReversedString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. Each byte is converted to 2 hex symbols; zero(es) included. The argument is treated as a large little-endian integer and is returned as a large big-endian integer.This method calls the method with same name and three arguments as:
toReversedString(ba, 0, ba.length);
- Parameters:
ba
- the byte array to convert.
- Returns:
- a string of hexadecimal characters (two for each byte) representing the designated input byte array.
public static final String toReversedString(byte[] ba, int offset, int length)
Returns a string of hexadecimal digits from a byte array, starting atoffset
and consisting oflength
bytes. Each byte is converted to 2 hex symbols; zero(es) included.The byte array is treated as a large little-endian integer, and is returned as a large big-endian integer.
- Parameters:
ba
- the byte array to convert.offset
- the index from which to start considering the bytes to convert.length
- the count of bytes, starting from the designated offset to convert.
- Returns:
- a string of hexadecimal characters (two for each byte) representing the designated input byte sub-array.
public static String toString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. Each byte is converted to 2 hex symbols; zero(es) included.This method calls the method with same name and three arguments as:
toString(ba, 0, ba.length);
- Parameters:
ba
- the byte array to convert.
- Returns:
- a string of hexadecimal characters (two for each byte) representing the designated input byte array.
public static final String toString(byte[] ba, int offset, int length)
Returns a string of hexadecimal digits from a byte array, starting atoffset
and consisting oflength
bytes. Each byte is converted to 2 hex symbols; zero(es) included.
- Parameters:
ba
- the byte array to convert.offset
- the index from which to start considering the bytes to convert.length
- the count of bytes, starting from the designated offset to convert.
- Returns:
- a string of hexadecimal characters (two for each byte) representing the designated input byte sub-array.
public static String toString(int n)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the unsigned integern
.
- Parameters:
n
- the unsigned integer to convert.
- Returns:
- a hexadecimal string 8-character long.
public static String toString(int[] ia)
Returns a string of hexadecimal digits from an integer array. Each int is converted to 4 hex symbols.
public static String toString(long n)
Returns a string of 16 hexadecimal digits (most significant digit first) corresponding to the unsigned longn
.
- Parameters:
n
- the unsigned long to convert.
- Returns:
- a hexadecimal string 16-character long.
public static String toUnicodeString(byte[] ba)
Similar to thetoString()
method except that the Unicode escape character is inserted before every pair of bytes. Useful to externalise byte arrays that will be constructed later from such strings; eg. s-box values.
- Throws:
ArrayIndexOutOfBoundsException
- if the length is odd.
public static final String toUnicodeString(byte[] ba, int offset, int length)
Similar to thetoString()
method except that the Unicode escape character is inserted before every pair of bytes. Useful to externalise byte arrays that will be constructed later from such strings; eg. s-box values.
- Throws:
ArrayIndexOutOfBoundsException
- if the length is odd.
public static String toUnicodeString(int[] ia)
Similar to thetoString()
method except that the Unicode escape character is inserted before every pair of bytes. Useful to externalise integer arrays that will be constructed later from such strings; eg. s-box values.
- Throws:
ArrayIndexOutOfBoundsException
- if the length is not a multiple of 4.
public static final byte[] trim(BigInteger n)
Treats the input as the MSB representation of a number, and discards leading zero elements. For efficiency, the input is simply returned if no leading zeroes are found.
- Parameters:
n
- theBigInteger
to trim.
- Returns:
- the byte array representation of the designated
BigInteger
with no leading 0-bytes.