org.norther.tammi.acorn.security
Class RNG

java.lang.Object
  extended by org.norther.tammi.acorn.security.RNG

public abstract class RNG
extends Object

A static random id and number generator.

Version:
$Id: RNG.java,v 1.8 2009/09/28 15:08:48 cvsimp Exp $
Author:
Ilkka Priha

Field Summary
static int DEFAULT_LENGTH
          The default length of the id.
 
Constructor Summary
RNG()
           
 
Method Summary
static String generate()
          Generates a random id of the default length.
static String generate(int n)
          Generates a random id of n chars.
static SecureRandom getSecureRandom()
          Gets the randomizer applied.
static long longCount()
          Returns the long count.
static void nextBytes(byte[] random)
          Returns the specified number of random bytes.
static int nextCount()
          Returns the next count.
static int nextInt()
          Returns a random int.
static int nextInt(int n)
          Returns a random int within 0 - n.
static long nextLong()
          Returns a random long.
static String password(int n)
          Generates a random password of n chars.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LENGTH

public static final int DEFAULT_LENGTH
The default length of the id.

See Also:
Constant Field Values
Constructor Detail

RNG

public RNG()
Method Detail

generate

public static final String generate()
Generates a random id of the default length.

Returns:
the random id.

generate

public static final String generate(int n)
Generates a random id of n chars.

Parameters:
n - the number of chars.
Returns:
the random id.

password

public static final String password(int n)
Generates a random password of n chars.

Parameters:
n - the number of chars.
Returns:
the random password.

longCount

public static final long longCount()
Returns the long count.

Returns:
the long count.

nextCount

public static final int nextCount()
Returns the next count.

Returns:
the count.

nextInt

public static final int nextInt()
Returns a random int.

Returns:
the int.

nextInt

public static final int nextInt(int n)
Returns a random int within 0 - n.

Parameters:
n - the limit.
Returns:
the int.

nextLong

public static final long nextLong()
Returns a random long.

Returns:
the long.

nextBytes

public static final void nextBytes(byte[] random)
Returns the specified number of random bytes.

Parameters:
random - the byte array to fill.

getSecureRandom

public static final SecureRandom getSecureRandom()
Gets the randomizer applied.

Returns:
the randomizer.


Copyright © 2004 The Norther Organization. All rights reserved.