Reputation: 191
I'm trying to set up AES encryption for an application and Eclipse is throwing the following errors:
"Multiple markers at this line
- Syntax error on tokens, ConstructorHeaderName expected instead
- Syntax error on token "(", < expected
- Syntax error on tokens, ConstructorHeaderName expected instead"
on lines
enccipher.init(Cipher.ENCRYPT_MODE, secretkey);
and
deccipher.init(Cipher.DECRYPT_MODE, secretkey, new IvParameterSpec(iv));
Here is my code:
private final byte[] salt = new SecureRandom().generateSeed(8);
SecretKeyFactory fact = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec spec = new PBEKeySpec(null, salt, 65536, 256);
SecretKey tempsecret = fact.generateSecret(spec);
private SecretKey secret = new SecretKeySpec(tempsecret.getEncoded(), "AES");
private Cipher enccipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
enccipher.init(Cipher.ENCRYPT_MODE, secret);
private final byte[] iv = enccipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
private Cipher deccipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
deccipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv));
protected byte[] doEncrypt(String pass){
return enccipher.doFinal(pass.getBytes());
}
protected String doDecrypt(byte[] ciphertext) {
return new String (deccipher.doFinal(ciphertext), "UTF8");
}
Upvotes: 0
Views: 386
Reputation: 14376
Post your code - but my guess is that you're just entering text into the class body (where it says does not go not here
) instead of inside methods (where it says code goes here
).
public class XYZ {
// variable and method declarations go here
// code does not go here
public XYZ () {
// code goes here
}
}
Upvotes: 4