== How to fix it in Cryptodome

=== Code examples

==== Noncompliant code example

[source,python,diff-id=11,diff-type=noncompliant]
----
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad

iv     = b"exampleIV1234567"
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher.encrypt(pad(data, AES.block_size))  # Noncompliant
----

==== Compliant solution

:explicit_strong: Crypto.Random.get_random_bytes

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

[source,python,diff-id=11,diff-type=compliant]
----
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad

iv     = get_random_bytes(AES.block_size)
cipher = AES.new(key, AES.MODE_CBC, iv)
cipher.encrypt(pad(data, AES.block_size))
----

=== How does this work?

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

