38 lines
605 B
Plaintext
38 lines
605 B
Plaintext
== How to fix it in .NET
|
|
|
|
=== Code examples
|
|
|
|
include::../../common/fix/code-rationale.adoc[]
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=11,diff-type=noncompliant]
|
|
----
|
|
using System.Security.Cryptography;
|
|
|
|
public void encrypt()
|
|
{
|
|
var simpleDES = new DESCryptoServiceProvider(); // Noncompliant
|
|
}
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=11,diff-type=compliant]
|
|
----
|
|
using System.Security.Cryptography;
|
|
|
|
public void encrypt()
|
|
{
|
|
using (Aes aes = Aes.Create())
|
|
{
|
|
// ...
|
|
}
|
|
}
|
|
----
|
|
|
|
=== How does this work?
|
|
|
|
include::../../common/fix/strong-cryptography.adoc[]
|
|
|