Skip to Content
0
Jun 19, 2020 at 04:37 PM

GCM can not be used with class javax.crypto.spec.GCMParameterSpec

674 Views Last edit Jun 15, 2021 at 07:06 AM 2 rev

In EP portal, I'm Encrypting the data with "AES/GCM/NoPadding" algorithm, before cipher init method I'm getting java.security.InvalidAlgorithmParameterException: GCM can not be used with class javax.crypto.spec.GCMParameterSpec error, is there any specific reason for this??

<code>Cipher cipher =Cipher.getInstance("AES/GCM/NoPadding");GCMParameterSpec parameterSpec =newGCMParameterSpec(128, iv);SecretKeySpec keySpec =newSecretKeySpec(key,"AES");
cipher.init(Cipher.ENCRYPT_MODE, keySpec, parameterSpec);