Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mozilla.jss.util
Class UTF8Converter

    java.lang.Object
      |
      +--org.mozilla.jss.util.UTF8Converter

public class UTF8Converter
extends java.lang.Object

Class for converting between char arrays and byte arrays. The conversion is guaranteed (in optimized mode only) not to leave any data hanging around in memory unless there is a catastrophic VM error, which is useful for encoding passwords.

Constructor Summary
`UTF8Converter()`

Method Summary
`static void` | `main(java.lang.String[] args)` Testing method
`static byte[]` | `UnicodeToUTF8(char[] unicode)` Creates a new UTF8-encoded byte array representing the char[] passed in.
`protected static byte[]` | `UnicodeToUTF8(char[] unicode, boolean nullTerminate)` Do the work of the above functions.
`static byte[]` | `UnicodeToUTF8NullTerm(char[] unicode)` Creates a new null-terminated UTF8-encoded byte array representing the char[] passed in.
`static void` | `wipeBytes(byte[] array)` Wipes a byte array by setting all of its bytes to zero.

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

Constructor Detail

### UTF8Converter

    public UTF8Converter()

Method Detail

### UnicodeToUTF8

    public static byte[] UnicodeToUTF8(char[] unicode)
                                throws java.io.CharConversionException

  Creates a new UTF8-encoded byte array representing the char[] passed in. The output array will NOT be null-terminated.

  This call is safe for passwords; all internal buffers are cleared. The output array is the owned by the caller, who has responsibility for clearing it.

  See http://www.stonehard.com/unicode/standard/ for the UTF-16 and UTF-8 standards.

  Parameters:
    `unicode` - An array of Unicode characters, which may have UCS4 characters encoded in UTF-16. This array must not be null.
  Throws:
    `java.io.CharConversionException` - If the input characters are invalid.

### UnicodeToUTF8NullTerm

    public static byte[] UnicodeToUTF8NullTerm(char[] unicode)
                                        throws java.io.CharConversionException

  Creates a new null-terminated UTF8-encoded byte array representing the char[] passed in.

  This call is safe for passwords; all internal buffers are cleared. The output array is the owned by the caller, who has responsibility for clearing it.

  See http://www.stonehard.com/unicode/standard/ for the UTF-16 and UTF-8 standards.

  Parameters:
    `unicode` - An array of Unicode characters, which may have UCS4 characters encoded in UTF-16. This array must not be null.
  Throws:
    `java.io.CharConversionException` - If the input characters are invalid.

### UnicodeToUTF8

    protected static byte[] UnicodeToUTF8(char[] unicode,
                                          boolean nullTerminate)
                                   throws java.io.CharConversionException

  Do the work of the above functions.

    `java.io.CharConversionException`

### wipeBytes

    public static void wipeBytes(byte[] array)

  Wipes a byte array by setting all of its bytes to zero.

  Parameters:
    `array` - The input array must not be null.

### main

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

  Testing method

Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD