Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i encrypt a field

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
US
Hi all,
i need to encrypt a password field in a table, just in case anyone open the table, they would not be able to read averyone's passwords.

And also i need to DISABLE the function keys.

Any help is appreciated.
 
A simple method of encryption would be to Xor the Asci value of each character, although this is very easy to break by a determine hacker it will confuse the average user.

Code:
Function Crypter(pStrSent As String) As String
  Dim i As Integer
  Dim NewLetter As String
  For i = 1 to Len(pStrSent)
    NewLetter = Asc(Mid(pStrSent,i,1)) Xor 5
    Crypter = Crypter & NewLetter
  Next i
End Function

To Call it open your table through code and send each record's password field like

Code:
  Dim NewPass As String
  Dim Db As DAO.Database
  Dim Rc As DAO.Recordset
  Set Db = CurrentDb
  Set Rc = Db.OpenRecordset("User's Table")
  Do While Not Rc.EOF
    Rc.Edit
    NewPass = Crypter(Rc!PasswordField)
    Rc!PasswordField = NewPass
    Rc.Update
    Rc.MoveNext
  Loop
  Set Rc = Nothing
  Set Db = Nothing

To reverse the encryption send the encrypted text back to the Crypter Function..
Rc.Close

Danny

Never Think Impossible
 
Hm,

I'm wondering why you have a table with passwaords. Access security (although also hackable with tools) encrypts the table with passwords. Did you write your own security?

To disable F keys look into the startup options (menu>>extra).
And to disable the shiftkey you could use:

Code:
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer

Dim dbs As Object, prp As Variant
Set dbs = CurrentDb
Const conPropNotFoundError = 3270

On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
    If Err = conPropNotFoundError Then ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
        dbs.Properties.Append prp
        Resume Next
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    End If

End Function

Please also check the forum, there are a lot of threads about disableing the shiftkey.


Easyit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top