Code example for InvalidKeyException

Methods: getMessage

0
			final SecretKeySpec key = new SecretKeySpec(strkey.getBytes(), "Blowfish");
		    final Cipher cipher = Cipher.getInstance("Blowfish");
		    cipher.init(Cipher.ENCRYPT_MODE, key);
		    return new String(cipher.doFinal(toEncrypt.getBytes()));
		}catch(InvalidKeyException ike){
			logger.warning("InvalidKeyException occured: " + ike.getMessage());
			return null; 
		} catch (NoSuchAlgorithmException e) {
			logger.warning("NoSuchAlgorithmException occured: " + e.getMessage());
			return null; 
		} catch (NoSuchPaddingException e) {
			logger.warning("NoSuchPaddingException occured: " + e.getMessage());
			return null; 
		} catch (IllegalBlockSizeException e) {
			logger.warning("IllegalBlockSizeException occured: " + e.getMessage());
			return null; 
		} catch (BadPaddingException e) {
			logger.warning("BadPaddingException occured: " + e.getMessage());
			return null; 
		} 
	}