38 lines
603 B
Plaintext
38 lines
603 B
Plaintext
![]() |
== How to fix it in .NET
|
||
|
|
||
|
=== Code examples
|
||
|
|
||
|
include::../../common/fix/code-rationale.adoc[]
|
||
|
|
||
|
==== Noncompliant code example
|
||
|
|
||
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
||
|
----
|
||
|
using System.Security.Cryptography;
|
||
|
|
||
|
public void encrypt()
|
||
|
{
|
||
|
var simpleDES = new DESCryptoServiceProvider(); // Noncompliant
|
||
|
}
|
||
|
----
|
||
|
|
||
|
==== Compliant solution
|
||
|
|
||
|
[source,csharp,diff-id=1,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[]
|
||
|
|