Public Function XOREncryption(strCodeKey As String, _ strDataIn As String) As String Dim lonDataPtr As Long Dim intXORValue1 As Integer Dim intXORValue2 As Integer Dim strDataOut As String For lonDataPtr = 1 To Len(strDataIn) ' The first value to XOR comes from the data to be ' encrypted. intXORValue1 = Asc(Mid$(strDataIn, lonDataPtr, 1)) ' The second value to XOR comes from the code key. intXORValue2 = Asc(Mid$(strCodeKey, _ ((lonDataPtr Mod Len(strCodeKey)) + 1), 1)) ' The two values are XORed together to create a ' decrypted character. strDataOut = strDataOut + Chr(intXORValue1 Xor _ intXORValue2) Next lonDataPtr ' The XOREncryption function returns the encrypted (or ' decrypted) data. XOREncryption = strDataOut End Function To try out the XOREncryption routine, you can add it to a form that has three TextBox controls (Text1, Text2, and Text3) and a CommandButton control. In the CommandButton's Click event, add the following code: Dim strCodeKey As String Dim strEncryptedText As String strCodeKey = "Wxz19hgl3Kb2dSp" strEncryptedText = XOREncryption(strCodeKey, Text1.Text) Text2.Text = strEncryptedText Text3.Text = XOREncryption(strCodeKey, strEncryptedText)