By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

encode/decoder algorithm to secure password

P: 1
Hi,

I am using VB6 and SQL Server 2000.

I want to design a logon form. In this form, how can I use a Password field to store in encrypted form in tbluser table and how can I compare password text in this table?

Please tell me how I can use encode/decoder algorithm to secure password.

User form coding is as follows :-

Expand|Select|Wrap|Line Numbers
  1. Dim sql As String
  2. Dim adcon As ADODB.Connection
  3. Dim rs As ADODB.Recordset
  4. Dim sqldata As String
  5.  
  6. Private Sub Form_Load()
  7.     'get a connection
  8.     cmd = "Provider=sqloledb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
  9.     Set adcon = New ADODB.Connection
  10.     adcon.Open cmd
  11.     sqldata = "select * from tbluser"
  12.     'Set new ADO recordset object
  13.     Set rs = New ADODB.Recordset
  14.     rs.Open sqldata, adcon, adOpenStatic, adLockOptimistic    
  15. End Sub
  16.  
  17. Private Sub cmdAdd_Click()
  18.     'Coding to clear the text box
  19.     txtId.Text = ""
  20.     txtUser.Text = ""
  21.     txtPassword.Text = ""
  22.     'txtDId.SetFocus
  23.     rs.AddNew
  24. End Sub
  25.  
  26. Private Sub cmdSave_Click()
  27.         rs(0) = txtId.Text
  28.         rs(1) = txtUser.Text
  29.     '**** I Want to save this field in encrypted form in SQL Server 2000 in table tbluser ! pls help me ****
  30.         rs(2) = txtPassword.Text
  31.         rs.Update
  32.         MsgBox "Entry  Saved"
  33.         rs.Requery        
  34. End Sub

Login form coding is as follows :-

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim adcon As ADODB.Connection
  3. Dim rs As ADODB.Recordset
  4. Dim sqldata As String
  5. Dim cmd As String
  6. Public LoginSucceeded As Boolean
  7.  
  8. Private Sub Form_Load()
  9.    'get a connection
  10.     cmd = "Provider=sqloledb;" & "Data Source=xyz;" & "Initial Catalog=edp07;" & "User Id=sa;"
  11.     Set adcon = New ADODB.Connection
  12.     adcon.Open cmd
  13.     sqldata = "select * from tbluser"
  14.     'Set new ADO recordset object
  15.     Set rs = New ADODB.Recordset
  16.     rs.Open sqldata, adcon, adOpenStatic, adLockOptimistic    
  17. End Sub
  18.  
  19. Private Sub cmdOK_Click()
  20.     'check for correct password
  21.     If rs.RecordCount = 0 Then
  22.         MsgBox ("No recordset")
  23.         Exit Sub
  24.     End If
  25.     'check for correct username and password
  26.     rs.MoveFirst
  27.     Do While Not rs.EOF
  28.     If txtUserName = RTrim(rs.Fields("name")) Then
  29. '**** I Want to compare encrypted data in SQL Server 2000 in table tbl user! Please help me ****
  30.         If txtPassword = RTrim(rs.Fields("Password")) Then
  31.             LoginSucceeded = True
  32.             Me.Hide
  33.             Form1.Show
  34.        End If
  35.     End If
  36.     rs.MoveNext
  37.     Loop
  38.     If Not LoginSucceeded Then
  39.         MsgBox "Invalid UserName/Password, try again!", , "Login"
  40.         txtPassword.SetFocus
  41.         SendKeys "{Home}+{End}"
  42.     End If
  43. End Sub
Can anyone help?

Thanks.

pawan
Sep 12 '07 #1
Share this Question
Share on Google+
1 Reply


hariharanmca
100+
P: 1,977
Try it your self to encode and decode the data. We will help you.
Sep 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.