All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.util.core.Hex

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

public class Hex
extends Object
Static methods for converting to and from hexadecimal strings.

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

$Revision: 1.1.1.1 $

Author:
David Hopwood, Raif Naffah, Systemics Ltd

Method Index

 o byteToString(int)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of n.
 o dumpString(byte[])
 o dumpString(byte[], int, int)
 o dumpString(byte[], int, int, String)
Dump a byte array as a string, in a format that is easy to read for debugging.
 o dumpString(byte[], String)
 o fromDigit(char)
Returns the number from 0 to 15 corresponding to the hex digit ch.
 o fromReversedString(String)
Returns a byte array from a string of hexadecimal digits in reverse order (i.e.
 o fromString(String)
Returns a byte array from a string of hexadecimal digits.
 o intToString(int)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n, which is treated as unsigned.
 o longToString(long)
Returns a string of 16 hexadecimal digits (most significant digit first) corresponding to the long n, which is treated as unsigned.
 o main(String[])
 o self_test(PrintWriter)
 o shortToString(int)
Returns a string of 4 hexadecimal digits (most significant digit first) corresponding to the lowest 16 bits of n.
 o toDigit(int)
Returns the hex digit corresponding to a number n, from 0 to 15.
 o toReversedString(byte[])
 o toReversedString(byte[], int, int)
Returns a string of hexadecimal digits in reverse order from a byte array (i.e.
 o toString(byte[])
 o toString(byte[], int, int)
Returns a string of hexadecimal digits from a byte array.
 o toString(int[])
 o toString(int[], int, int)
Returns a string of hexadecimal digits from an integer array.

Methods

 o toString
 public static String toString(byte ba[],
                               int offset,
                               int length)
Returns a string of hexadecimal digits from a byte array. Each byte is converted to 2 hex symbols.

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

 o toString
 public static String toString(byte ba[])
 o toString
 public static String toString(int ia[],
                               int offset,
                               int length)
Returns a string of hexadecimal digits from an integer array. Each int is converted to 4 hex symbols.

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

 o toString
 public static String toString(int ia[])
 o toReversedString
 public static String toReversedString(byte b[],
                                       int offset,
                                       int length)
Returns a string of hexadecimal digits in reverse order from a byte array (i.e. the least significant byte is first, but within each byte the most significant hex digit is before the least significant hex digit).

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

 o toReversedString
 public static String toReversedString(byte b[])
 o fromString
 public static byte[] fromString(String hex)
Returns a byte array from a string of hexadecimal digits.

 o fromReversedString
 public static byte[] fromReversedString(String hex)
Returns a byte array from a string of hexadecimal digits in reverse order (i.e. the least significant byte is first, but within each byte the most significant hex digit is before the least significant hex digit). The string must have an even number of digits.

This is not really either little nor big-endian; it's just obscure. It is here because it is the format used for the SPEED certification data.

 o toDigit
 public static char toDigit(int n)
Returns the hex digit corresponding to a number n, from 0 to 15.

 o fromDigit
 public static int fromDigit(char ch)
Returns the number from 0 to 15 corresponding to the hex digit ch.

 o byteToString
 public static String byteToString(int n)
Returns a string of 2 hexadecimal digits (most significant digit first) corresponding to the lowest 8 bits of n.

 o shortToString
 public static String shortToString(int n)
Returns a string of 4 hexadecimal digits (most significant digit first) corresponding to the lowest 16 bits of n.

 o intToString
 public static String intToString(int n)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n, which is treated as unsigned.

 o longToString
 public static String longToString(long n)
Returns a string of 16 hexadecimal digits (most significant digit first) corresponding to the long n, which is treated as unsigned.

 o dumpString
 public static String dumpString(byte data[],
                                 int offset,
                                 int length,
                                 String m)
Dump 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 and length are omitted, the whole array is used. If m 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 dump.
 o dumpString
 public static String dumpString(byte data[])
 o dumpString
 public static String dumpString(byte data[],
                                 String m)
 o dumpString
 public static String dumpString(byte data[],
                                 int offset,
                                 int length)
 o main
 public static void main(String args[])
 o self_test
 public static void self_test(PrintWriter out)

All Packages  Class Hierarchy  This Package  Previous  Next  Index