== How to fix it in Java Cryptographic Extension === Code examples include::../../common/fix/code-rationale.adoc[] ==== Noncompliant code example [source,kotlin,diff-id=1,diff-type=noncompliant] ---- import javax.crypto.NoSuchPaddingException import java.security.NoSuchAlgorithmException import javax.crypto.Cipher fun main(args: Array) { try { val des = Cipher.getInstance("DES") // Noncompliant } catch (e: NoSuchAlgorithmException) { // ... } catch (e: NoSuchPaddingException) { // ... } } ---- ==== Compliant solution [source,kotlin,diff-id=1,diff-type=compliant] ---- import javax.crypto.NoSuchPaddingException import java.security.NoSuchAlgorithmException import javax.crypto.Cipher fun main(args: Array) { try { val aes = Cipher.getInstance("AES/GCM/NoPadding") } catch (e: NoSuchAlgorithmException) { // ... } catch (e: NoSuchPaddingException) { // ... } } ---- === How does this work? include::../../common/fix/strong-cryptography.adoc[]