Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Hash Issues

$
0
0

I have some simple hash encryption code that encrypts a password.
Here's my code behind:

    Protected Sub btUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btUpdate.Click
        Dim hashword As New Cryptography.SHA1CryptoServiceProvider
        Dim passworddata(50) As Byte
        Dim hashresult As String
        Dim encoding As New System.Text.UTF8Encoding


        If (Page.IsValid) Then

            passworddata = encoding.GetBytes(tbPassword.Text)
            hashresult = encoding.GetString(hashword.ComputeHash(passworddata))

            'Using conn As New SqlConnection("Data Source=SLOTS;Initial Catalog=RTT_DEV;Integrated Security=True")
            Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("RTT_DEVConnectionString").ConnectionString)
                Using cmd As New SqlCommand("UPDATE [Users] SET [Username] = @Username, [PASSWORD] = @PASSWORD, [UserType] = @UserType, [TerminalOperatorNum] = @TerminalOperatorNum, [FirstName] = @FirstName, [LastName] = @LastName WHERE [Logid] = @Logid", conn)
                    cmd.Parameters.AddWithValue("PASSWORD", hashresult)
                    conn.Open()
                    Dim Reader = cmd.ExecuteReader()
                    If Reader.HasRows Then
                        While Reader.Read
                        End While
                    End If
                    conn.Close()
                    Literal1.Text = "Information Updated"
                    Literal1.Visible = True
                End Using
            End Using

        End If

    End Sub

The program sends one thing and SQL shows something else.The table field is scripted as: [PASSWORD] [varchar](50) NULL,
Why does SQL Server change the data coming in?


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>