|
|||||||||
Home >> All >> gnu >> java >> security >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
gnu.java.security.util
Class Util

java.lang.Objectgnu.java.security.util.Util
- public class Util
- extends java.lang.Object
A collection of utility methods used throughout this project.
Field Summary | |
private static java.lang.String |
BASE64_CHARS
|
private static char[] |
BASE64_CHARSET
|
private static char[] |
HEX_DIGITS
|
Constructor Summary | |
private |
Util()
Trivial constructor to enforce Singleton pattern. |
Method Summary | |
static java.lang.String |
byteToString(int n)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of n . |
static java.lang.String |
dump(java.math.BigInteger x)
Returns a hexadecimal dump of the trimmed bytes of a java.math.BigInteger. |
static java.lang.String |
dumpString(byte[] data)
|
static java.lang.String |
dumpString(byte[] data,
int offset,
int length)
|
static java.lang.String |
dumpString(byte[] data,
int offset,
int length,
java.lang.String m)
Dumps a byte array as a string, in a format that is easy to read for debugging. |
static java.lang.String |
dumpString(byte[] data,
java.lang.String m)
|
static byte[] |
fromBase64(java.lang.String str)
The inverse function of the above. |
static int |
fromDigit(char c)
Returns a number from 0 to 15 corresponding
to the designated hexadecimal digit. |
static java.lang.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). |
static byte[] |
toBytesFromString(java.lang.String s)
Returns a byte array from a string of hexadecimal digits. |
static byte[] |
toBytesFromUnicode(java.lang.String s)
|
static byte[] |
toReversedBytesFromString(java.lang.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. |
static java.lang.String |
toReversedString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. |
static java.lang.String |
toReversedString(byte[] ba,
int offset,
int length)
Returns a string of hexadecimal digits from a byte array, starting at offset and consisting of length bytes. |
static java.lang.String |
toString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. |
static java.lang.String |
toString(byte[] ba,
int offset,
int length)
Returns a string of hexadecimal digits from a byte array, starting at offset and consisting of length bytes. |
static java.lang.String |
toString(int n)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the unsigned integer n . |
static java.lang.String |
toString(int[] ia)
Returns a string of hexadecimal digits from an integer array. |
static java.lang.String |
toString(long n)
Returns a string of 16 hexadecimal digits (most significant digit first) corresponding to the unsigned long n . |
static java.lang.String |
toUnicodeString(byte[] ba)
Similar to the toString() method except that the Unicode
escape character is inserted before every pair of bytes. |
static java.lang.String |
toUnicodeString(byte[] ba,
int offset,
int length)
Similar to the toString() method except that the Unicode
escape character is inserted before every pair of bytes. |
static java.lang.String |
toUnicodeString(int[] ia)
Similar to the toString() method except that the Unicode
escape character is inserted before every pair of bytes. |
static byte[] |
trim(java.math.BigInteger n)
Treats the input as the MSB representation of a number, and discards leading zero elements. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
HEX_DIGITS
private static final char[] HEX_DIGITS
BASE64_CHARS
private static final java.lang.String BASE64_CHARS
- See Also:
- Constant Field Values
BASE64_CHARSET
private static final char[] BASE64_CHARSET
Constructor Detail |
Util
private Util()
- Trivial constructor to enforce Singleton pattern.
Method Detail |
toString
public static java.lang.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);
toString
public static final java.lang.String toString(byte[] ba, int offset, int length)
Returns a string of hexadecimal digits from a byte array, starting at
offset
and consisting oflength
bytes. Each byte is converted to 2 hex symbols; zero(es) included.
toReversedString
public static java.lang.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);
toReversedString
public static final java.lang.String toReversedString(byte[] ba, int offset, int length)
Returns a string of hexadecimal digits from a byte array, starting at
offset
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.
toBytesFromString
public static byte[] toBytesFromString(java.lang.String s)
Returns a byte array from a string of hexadecimal digits.
toReversedBytesFromString
public static byte[] toReversedBytesFromString(java.lang.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.
fromDigit
public static int fromDigit(char c)
Returns a number from
0
to15
corresponding to the designated hexadecimal digit.
toString
public static java.lang.String toString(int n)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the unsigned integer
n
.
toString
public static java.lang.String toString(int[] ia)
Returns a string of hexadecimal digits from an integer array. Each int is converted to 4 hex symbols.
toString
public static java.lang.String toString(long n)
Returns a string of 16 hexadecimal digits (most significant digit first) corresponding to the unsigned long
n
.
toUnicodeString
public static java.lang.String toUnicodeString(byte[] ba)
Similar to the
toString()
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.
toUnicodeString
public static final java.lang.String toUnicodeString(byte[] ba, int offset, int length)
Similar to the
toString()
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.
toUnicodeString
public static java.lang.String toUnicodeString(int[] ia)
Similar to the
toString()
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.
toBytesFromUnicode
public static byte[] toBytesFromUnicode(java.lang.String s)
dumpString
public static java.lang.String dumpString(byte[] data, int offset, int length, java.lang.String m)
Dumps a byte array as a string, in a format that is easy to read for debugging. The string
m
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.
dumpString
public static java.lang.String dumpString(byte[] data)
dumpString
public static java.lang.String dumpString(byte[] data, java.lang.String m)
dumpString
public static java.lang.String dumpString(byte[] data, int offset, int length)
byteToString
public static java.lang.String byteToString(int n)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of
n
.
toBase64
public static final java.lang.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.
fromBase64
public static final byte[] fromBase64(java.lang.String str)
The inverse function of the above.
Converts a string representing the encoding of some bytes in Base-64 to their original form.
trim
public static final byte[] trim(java.math.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.
dump
public static final java.lang.String dump(java.math.BigInteger x)
Returns a hexadecimal dump of the trimmed bytes of a java.math.BigInteger.
|
|||||||||
Home >> All >> gnu >> java >> security >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |