convert Byte Array to Secret Key

You need to use the new keyword to call the constructor and create the object.

SecretKey originalKey = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");

When you try to call it without new, the compiler thinks it might be a method you’ve defined inside that class, hence your error message.

Leave a Comment