sábado, 27 de noviembre de 2010

Crear una clave SHA1 como la generada por FormsAuthentication.HashPasswordForStoringInConfigFile

Private Function GenerateSHA1(ByVal nombre As String) As String
Dim enc As New UTF8Encoding
Dim data() As Byte = enc.GetBytes(nombre)
Dim result() As Byte
Dim sha As New SHA1CryptoServiceProvider
result = sha.ComputeHash(data)
Dim sb As New StringBuilder
For i As Integer = 0 To result.Length - 1
If result(i) < 16 Then sb.Append("0") End If sb.Append(result(i).ToString("x")) Next Return sb.ToString.ToUpper End Function

No hay comentarios:

Publicar un comentario