View Single Post
  #1 (permalink)  
Old January 23rd, 2007, 03:25 AM
keyvanjan keyvanjan is offline
Friend of Wrox
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default password encode sha1 all records

i have a table with 200 records which has a password field
the passwords are not encoded
i need a page with a button when i click the button then
it goes and updates all the password fields to sha1 encoded
i have written some codes but it does not work
please write me the code

  Dim strPW As String = ""
        Dim dr As SqlDataReader

        Dim sql As String = "Select password from members_bkp"

        Dim cnn As New SqlClient.SqlConnection(strConnection)

        Dim Cmd As New SqlCommand(Sql, cnn)

        dr = Cmd.ExecuteReader()
        Dim strPWEncoded As String = FormsAuthentication.HashPasswordForStoringInConfig File(dr("password"), "SHA1")
        Dim strSQL3 As String

        strSQL3 = "UPDATE members_bkp set password=@pwd"
        Cmd = New SqlCommand(strSQL3, cnn)
        Cmd.Parameters.Add(New SqlParameter("@pwd", strPWEncoded))

Reply With Quote