Class KeyGenerator
java.lang.Object
|
+--KeyGenerator
- public class KeyGenerator
- extends java.lang.Object
KeyGenerator.java
An object of this class has methods for creating keyfiles
for use with "One time pad" encryption. And consists of a series
of completly random bytes created by java.security.SecureRandom()
A KeyGenerator object can be used to create keyfiles from other
applications (such as MakeKey.java).
- Version:
- 1.2.0
LAST EDITED: 30.01.2001 <-little endian
- Author:
- Erlend Aakre, www.klogd.net
Inner Class Summary |
class |
KeyGenerator.ToFileThread
This inner class can be used by programs wich wants a
progessbars, or wants to run the process as a thread
The Thread version must be used like this:
KeyGenerator outerClass = new KeyGenerator();
KeyGenerator.ToFileThread keyGenerator = null;
keyGenerator = outerClass. |
Constructor Summary |
KeyGenerator()
Initializes the KeyGenerator using SUN's SHA1PRNG algorithm |
KeyGenerator(java.lang.String algorithm,
java.lang.String provider)
Initializes the KeyGenerator using specified provider and
algorithm |
Method Summary |
int[] |
toArray(int keyLength)
This method generates a key and puts it in a integer array |
boolean |
toFile(java.io.File file,
int keyLength)
This method generates a key and puts it in a file |
boolean |
toFile(java.lang.String fileName,
int keyLength)
This method generates a key and puts it in a file |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KeyGenerator
public KeyGenerator()
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
- Initializes the KeyGenerator using SUN's SHA1PRNG algorithm
- Parameters:
none
- - Throws:
java.security.NoSuchAlgorithmException
- If algorithm is not foundjava.security.NoSuchProviderException
- If the provieder is not found
KeyGenerator
public KeyGenerator(java.lang.String algorithm,
java.lang.String provider)
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException
- Initializes the KeyGenerator using specified provider and
algorithm
- Parameters:
algorithm
- The name of tha algorithm to useprovider
- The name of the provider who provides the
algorithm- Throws:
java.security.NoSuchAlgorithmException
- If algorithm is not foundjava.security.NoSuchProviderException
- If the provieder is not found
toFile
public boolean toFile(java.io.File file,
int keyLength)
throws java.io.IOException,
java.io.FileNotFoundException
- This method generates a key and puts it in a file
- Parameters:
file
- File object to write tokeyLength
- Number of bytes to write- Returns:
- Shows if the method was successful
toFile
public boolean toFile(java.lang.String fileName,
int keyLength)
throws java.io.IOException,
java.io.FileNotFoundException
- This method generates a key and puts it in a file
- Parameters:
fileName
- file to write key tokeyLength
- number of bytes to writeShows
- if the method was successful
toArray
public int[] toArray(int keyLength)
- This method generates a key and puts it in a integer array
- Parameters:
keyLength
- number of bytes to create- Returns:
- Array containing the random bytes