All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.util.core.ArrayUtil

java.lang.Object
   |
   +----cryptix.util.core.ArrayUtil

public class ArrayUtil
extends Object
Static methods for converting between arrays of various types, for clearing all or part of a byte array, and for comparing two byte arrays.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.2 $

Author:
Raif Naffah, David Hopwood

Method Index

 o areEqual(byte[], byte[])
Compares two byte arrays for equality.
 o areEqual(int[], int[])
Compares two int arrays for equality.
 o clear(byte[])
Clears a byte array to all-zeroes.
 o clear(byte[], int, int)
Clears length bytes of a byte array to zeroes, starting at offset.
 o compared(byte[], byte[], boolean)
 o toBytes(int)
Returns a 4-byte array built from an int.
 o toBytes(short[])
 o toBytes(short[], int, int)
Returns a byte array built from a short array.
 o toInt(short, short)
Returns an int built from two shorts.
 o toShort(byte, byte)
Returns a short built from two bytes.
 o toShorts(byte[])
 o toShorts(byte[], int, int)
Returns a short array built from a byte array.

Methods

 o clear
 public static void clear(byte buf[])
Clears a byte array to all-zeroes.

 o clear
 public static void clear(byte buf[],
                          int offset,
                          int length)
Clears length bytes of a byte array to zeroes, starting at offset.

 o toInt
 public static int toInt(short s0,
                         short s1)
Returns an int built from two shorts.

Parameters:
s0 - the least significant short
s1 - the most significant short
 o toShort
 public static short toShort(byte b0,
                             byte b1)
Returns a short built from two bytes.

Parameters:
b0 - the least significant byte
b1 - the most significant byte
 o toBytes
 public static byte[] toBytes(int n)
Returns a 4-byte array built from an int. The int's MSB is first (big-endian order).

 o toBytes
 public static byte[] toBytes(short array[],
                              int offset,
                              int length)
Returns a byte array built from a short array. Each short is broken into 2 bytes with the short's MSB first (big-endian order).

If offset and length are omitted, the whole array is used.

 o toBytes
 public static byte[] toBytes(short array[])
 o toShorts
 public static short[] toShorts(byte array[],
                                int offset,
                                int length)
Returns a short array built from a byte array. Each 2 bytes form a short with the first byte as the short's MSB (big-endian order).

If offset and length are omitted, the whole array is used.

 o toShorts
 public static short[] toShorts(byte array[])
 o areEqual
 public static boolean areEqual(byte a[],
                                byte b[])
Compares two byte arrays for equality.

Returns:
true if the arrays have identical contents
 o areEqual
 public static boolean areEqual(int a[],
                                int b[])
Compares two int arrays for equality.

Returns:
true if the arrays have identical contents
 o compared
 public static int compared(byte a[],
                            byte b[],
                            boolean msbFirst)

All Packages  Class Hierarchy  This Package  Previous  Next  Index