Code example for KeyGenerator

Methods: generateKey, init

0
     */ 
    public Key generateKey() throws NoSuchAlgorithmException{
    	Key key = null;
    	if(keyGen == null){
    		keyGen = KeyGenerator.getInstance("AES");
    		keyGen.init(new SecureRandom());
    	} 
        key = keyGen.generateKey();
        return(key);
    } 
     
    /** 
     * Returns a key that is a constant. Used as a placeholder for the case 
     * where encryption is turned off. 
     * @return 
     */ 
    public Key generateDummyKey(){
    	return new DummyKey(); 
    } 
    /** 
     * Saves the key to the specified file as raw bytes.