|
For the latest news and information visit The GNU Crypto project |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gnu.crypto.util.Util
A collection of utility methods used throughout this project.
Method Summary | |
static boolean |
areEqual(byte[] a,
byte[] b)
Returns true if the two designated byte arrays are
(a) non-null, (b) of the same length, and (c) contain the same values. |
static int |
fromDigit(char c)
Returns a number from 0 to 15 corresponding
to the designated hexadecimal digit. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean areEqual(byte[] a, byte[] b)
Returns true
if the two designated byte arrays are
(a) non-null, (b) of the same length, and (c) contain the same values.
a
- the first byte array.b
- the second byte array.
true
if the two designated arrays contain the same
values. Returns false
otherwise.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);
ba
- the byte array to convert.
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 of length
bytes. Each byte
is converted to 2 hex symbols; zero(es) included.
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.
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);
ba
- the byte array to convert.
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 of length
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.
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.
public static byte[] toBytesFromString(java.lang.String s)
Returns a byte array from a string of hexadecimal digits.
s
- a string of hexadecimal ASCII characters
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.
s
- a string of hexadecimal ASCII characters
public static int fromDigit(char c)
Returns a number from 0
to 15
corresponding
to the designated hexadecimal digit.
c
- a hexadecimal ASCII symbol.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
.
n
- the unsigned integer to convert.
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.
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
.
n
- the unsigned long to convert.
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.
java.lang.ArrayIndexOutOfBoundsException
- if the length is odd.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.
java.lang.ArrayIndexOutOfBoundsException
- if the length is odd.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.
java.lang.ArrayIndexOutOfBoundsException
- if the length is not a multiple
of 4.public static byte[] toBytesFromUnicode(java.lang.String s)
|
For the latest news and information visit The GNU Crypto project |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |