== How to fix it in PyCrypto

=== Code examples

==== Noncompliant code example

include::../../common/fix/aes-noncompliant-example.adoc[]

[source,python,diff-id=11,diff-type=noncompliant]
----
from Crypto.Cipher import AES

AES.new(key, AES.MODE_ECB) # Noncompliant
----

include::../../common/fix/rsa-noncompliant-example.adoc[]

[source,python,diff-id=12,diff-type=noncompliant]
----
from Crypto.Cipher import PKCS1_v1_5

PKCS1_v1_5.new(key) # Noncompliant
----

==== Compliant solution

Since PyCrypto is not supported anymore, another library should be used.
In the current context, Cryptodome uses a similar API.

include::../../common/fix/aes-compliant-example.adoc[]

[source,python,diff-id=11,diff-type=compliant]
----
from Crypto.Cipher import AES

AES.new(key, AES.MODE_GCM)
----

include::../../common/fix/rsa-compliant-example.adoc[]

[source,python,diff-id=12,diff-type=compliant]
----
from Crypto.Cipher import PKCS1_OAEP

PKCS1_OAEP.new(key)
----

=== How does this work?

include::../../common/fix/fix.adoc[]
