Code example for PBEKeySpec

Methods: clearPassword

		 * We can now create a key from our salt (extracted just above), password, and iteration count. Same 
		 * procedure to create the key as in encrypt(). 
		PBEKeySpec keyspec = new PBEKeySpec(password, salt, ITERATION_COUNT);
		SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGORITHM);
		SecretKey key = skf.generateSecret(keyspec);
		 * Once again, create a PBEParameterSpec object and a Cipher object. 
		PBEParameterSpec paramspec = new PBEParameterSpec(salt, ITERATION_COUNT);
		Cipher cipher = Cipher.getInstance(ALGORITHM);
		cipher.init(Cipher.DECRYPT_MODE, key, paramspec);
		 * Decrypt the data. The parameters we pass into doFinal() instruct it to skip the first SALT_LENGTH 
		 * bytes of input (which are actually the salt), and then to encrypt the next (length - SALT_LENGTH) 
		 * bytes, which are the real ciphertext. 
		byte[] output = cipher.doFinal(input, SALT_LENGTH, input.length - SALT_LENGTH);
		/* Clear the password and return the generated plaintext. */ 
		return output;
Stop searching for code, let great code find you!  Add Codota to your java IDE