Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cryptix.util.core
Class Hex

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

public class Hex
extends java.lang.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.2 $

Since:
  Cryptix 2.2.0a, 2.2.2
Author:
  David Hopwood, Raif Naffah, Systemics Ltd

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` | `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)` Dump 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 java.lang.String` | `dumpString(int[] data)`
`static java.lang.String` | `dumpString(int[] data, int offset, int length)`
`static java.lang.String` | `dumpString(int[] data, int offset, int length, java.lang.String m)` Dump an int array as a string, in a format that is easy to read for debugging.
`static java.lang.String` | `dumpString(int[] data, java.lang.String m)`
`static int` | `fromDigit(char ch)` Returns the number from 0 to 15 corresponding to the hex digit ch.
`static byte[]` | `fromReversedString(java.lang.String hex)` Returns a byte array from a string of hexadecimal digits in reverse order (i.e.
`static byte[]` | `fromString(java.lang.String hex)` Returns a byte array from a string of hexadecimal digits.
`static java.lang.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.
`static java.lang.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.
`static void` | `main(java.lang.String[] args)`
`static void` | `self_test(java.io.PrintWriter out)`
`static java.lang.String` | `shortToString(int n)` Returns a string of 4 hexadecimal digits (most significant digit first) corresponding to the lowest 16 bits of n.
`static char` | `toDigit(int n)` Returns the hex digit corresponding to a number n, from 0 to 15.
`static java.lang.String` | `toReversedString(byte[] b)`
`static java.lang.String` | `toReversedString(byte[] b, int offset, int length)` Returns a string of hexadecimal digits in reverse order from a byte array (i.e.
`static java.lang.String` | `toString(byte[] ba)`
`static java.lang.String` | `toString(byte[] ba, int offset, int length)` Returns a string of hexadecimal digits from a byte array.
`static java.lang.String` | `toString(int[] ia)`
`static java.lang.String` | `toString(int[] ia, int offset, int length)` Returns a string of hexadecimal digits from an integer array.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### toString

    public static java.lang.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.

### toString

    public static java.lang.String toString(byte[] ba)

### toString

    public static java.lang.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.

### toString

    public static java.lang.String toString(int[] ia)

### toReversedString

    public static java.lang.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.

### toReversedString

    public static java.lang.String toReversedString(byte[] b)

### fromString

    public static byte[] fromString(java.lang.String hex)

  Returns a byte array from a string of hexadecimal digits.

### fromReversedString

    public static byte[] fromReversedString(java.lang.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.

### toDigit

    public static char toDigit(int n)

  Returns the hex digit corresponding to a number n, from 0 to 15.

### fromDigit

    public static int fromDigit(char ch)

  Returns the number from 0 to 15 corresponding to the hex digit ch.

### 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.

### shortToString

    public static java.lang.String shortToString(int n)

  Returns a string of 4 hexadecimal digits (most significant digit first) corresponding to the lowest 16 bits of n.

### intToString

    public static java.lang.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.

### longToString

    public static java.lang.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.

### dumpString

    public static java.lang.String dumpString(byte[] data,
                                              int offset,
                                              int length,
                                              java.lang.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.

### 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)

### dumpString

    public static java.lang.String dumpString(int[] data,
                                              int offset,
                                              int length,
                                              java.lang.String m)

  Dump an int 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 int[] to dump
    `offset` - The offset within data to start from
    `length` - The number of ints to dump
    `m` - A string to prepend to each line
  Returns:
    A String containing the dump.

### dumpString

    public static java.lang.String dumpString(int[] data)

### dumpString

    public static java.lang.String dumpString(int[] data,
                                              java.lang.String m)

### dumpString

    public static java.lang.String dumpString(int[] data,
                                              int offset,
                                              int length)

### main

    public static void main(java.lang.String[] args)

### self_test

    public static void self_test(java.io.PrintWriter out)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) 1995-2000 The Cryptix Foundation Ltd. All rights reserved.