== How to fix it in .NET

=== Code examples

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

==== Noncompliant code example

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Imports System.Security.Cryptography

Public Sub Hash(Password As String)
    Dim Salt As Byte() = Encoding.UTF8.GetBytes("salty")
    Dim Hashed As New Rfc2898DeriveBytes(Password, Salt) ' Noncompliant
End Sub
----

==== Compliant solution

[source,vbnet,diff-id=1,diff-type=compliant]
----
Imports System.Security.Cryptography

Public Sub Hash(Password As String)
    Dim Hashed As New Rfc2898DeriveBytes(Password, 32, 10000, HashAlgorithmName.SHA256)
End Sub
----

=== How does this work?

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

include::../../common/fix/auto-salt.adoc[]

