Essentially, the function gets the UTF8 encoded bytes of the password, and returns a hash of that value.
Here is what Reflector shows:
Public Shared Function HashPasswordFor StoringInConfig File(ByVal password As String, ByVal passwordFormat As String) As String
Dim buffer1 As Byte()
If (password Is Nothing) Then
Throw New ArgumentNullExc eption("passwor d")
End If
If (passwordFormat Is Nothing) Then
Throw New ArgumentNullExc eption("passwor dFormat")
End If
If (String.Compare (passwordFormat , "sha1", True, CultureInfo.Inv ariantCulture) = 0) Then
buffer1 = FormsAuthentica tion.GetMacFrom Blob(Encoding.U TF8.GetBytes(pa ssword))
Else
If (String.Compare (passwordFormat , "md5", True, CultureInfo.Inv ariantCulture) = 0) Then
buffer1 = FormsAuthentica tion.GetMD5From Blob(Encoding.U TF8.GetBytes(pa ssword))
Else
Throw New ArgumentExcepti on(HttpRuntime. FormatResourceS tring("InvalidA rgumentValue", "passwordFormat "))
End If
End If
Return MachineKey.Byte ArrayToHexStrin g(buffer1, 0)
End Function
Private Shared Function GetMacFromBlob( ByVal bDataIn As Byte()) As Byte()
Dim sha1 As SHA1 = SHA1.Create
Return sha1.ComputeHas h(bDataIn)
End Function
Private Shared Function GetMD5FromBlob( ByVal bDataIn As Byte()) As Byte()
Dim md1 As MD5 = MD5.Create
Return md1.ComputeHash (bDataIn)
End Function
[color=blue]
> Does somebody know how
> FormsAuthentica tion.HashPasswo rdForStoringInC onfigFile
> works inside?
>
>[/color]
Comment