Encryption in Access

C

Confused

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?
 
A

Arvin Meyer [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top