== How to fix it in Mcrypt

=== Code examples

include::../../common/fix/code-rationale.adoc[]

==== Noncompliant code example

[source,php,diff-id=1,diff-type=noncompliant]
----
mcrypt_encrypt(MCRYPT_DES, $key, $plaintext, $mode); // Noncompliant
----

==== Compliant solution

Mcrypt is deprecated and should not be used. You can use
https://www.php.net/manual/en/book.sodium.php[Sodium] instead.

[source,php,diff-id=1,diff-type=compliant]
----
sodium_crypto_aead_aes256gcm_encrypt($plaintext, '', $nonce, $key);
----

=== How does this work?

include::../../common/fix/strong-cryptography.adoc[]

