CThompson
02-27-2004, 04:44 AM
Can anyone help me out.
I have been playing with an encryption algorithm, however now that I have it the way I want, I find that the decryption algorithm won't work (yep, didn't think of this while I was playing around).
I want to stick with my new algorithm, but don't have a heap of experience with the XOR functions etc.
If anyone can help me work out some code to decrypt this..
Public Function XOREncryption(DataIn As String) As String
Dim lonDataPtr As Long
Dim strDataOut As String
Dim temp As Integer
Dim tempstring As String
Dim intXOrValue1 As Integer
Dim intXOrValue2 As Integer
For lonDataPtr = 1 To Len(DataIn)
'The first value to be XOr-ed comes from the data to be encrypted
intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
'The second value comes from the code key
intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
temp = (intXOrValue1 Xor intXOrValue2)
tempstring = Hex((temp Mod 16))
strDataOut = strDataOut + tempstring
Next lonDataPtr
XOREncryption = strDataOut
End Function
Any help kindly appreciated.
I have been playing with an encryption algorithm, however now that I have it the way I want, I find that the decryption algorithm won't work (yep, didn't think of this while I was playing around).
I want to stick with my new algorithm, but don't have a heap of experience with the XOR functions etc.
If anyone can help me work out some code to decrypt this..
Public Function XOREncryption(DataIn As String) As String
Dim lonDataPtr As Long
Dim strDataOut As String
Dim temp As Integer
Dim tempstring As String
Dim intXOrValue1 As Integer
Dim intXOrValue2 As Integer
For lonDataPtr = 1 To Len(DataIn)
'The first value to be XOr-ed comes from the data to be encrypted
intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
'The second value comes from the code key
intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
temp = (intXOrValue1 Xor intXOrValue2)
tempstring = Hex((temp Mod 16))
strDataOut = strDataOut + tempstring
Next lonDataPtr
XOREncryption = strDataOut
End Function
Any help kindly appreciated.