Package org.astrogrid.samp.hub

# Class KeyGenerator

java.lang.Object
org.astrogrid.samp.hub.KeyGenerator

public class KeyGenerator extends Object
Object which can generate a sequence of private keys. The values returned by the next() method should in general not be easy to guess.

Since:
  26 Oct 2010
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`KeyGenerator(String prefix, int nchar, Random random)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static Random`
`createRandom()`
Returns a new, randomly seeded, Random object.
`String`
`next()`
Returns the next key in the sequence.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### KeyGenerator

public KeyGenerator(String prefix, int nchar, Random random)
Constructor.

Parameters:
  `prefix` - prefix prepended to all generated keys
  `nchar` - number of characters in generated keys
  `random` - random number generator

## Method Details

### next

public String next()
Returns the next key in the sequence. Guaranteed different from any previous return value from this method.

Returns:
  key string

### createRandom

public static Random createRandom()
Returns a new, randomly seeded, Random object.

Returns:
  random