Confused said:
I need to encrypt just the employee number in my database and leave it
encrypted all the time to send to users. How can I di it in Access/Excel?
If you just need to hide the field, use the Password input mask. If you need
to encrypt, decrypt, here's some code that will:
Encrypt or decript using the same function:
Public Function Encrypt(ByVal strIn As String, ByVal strKey As String) As
String
On Error GoTo Error_Handler
Dim i As Integer
Dim bytData As Byte
Dim bytKey As Byte
Dim strEncrypted As String
Encrypt = vbNullString
For i = 1 To Len(strIn)
bytData = Asc(Mid(strIn, i, 1))
bytKey = Asc(Mid(strKey, (i Mod Len(strKey)) + 1))
strEncrypted = strEncrypted & Chr(bytData Xor bytKey)
Next i
If strEncrypted <> vbNullString Then
Encrypt = strEncrypted
End If
Exit_Here:
Exit Function
Error_Handler:
Resume Exit_Here
End Function
Now this is not high class encryption, but, like a lock, it will keep out an
honest person.