Encryption/Decryption

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.

tinyjack
02-27-2004, 07:26 AM
Is your data to be encrypted plain text?

Because if it is you will not be able to decrypt it due to this line:


tempstring = Hex((temp Mod 16))


temp Mod 16, can only return 0 to 15 which is not enough to represent all the letters.

Maybe have a look at this:

http://www.visualbasicforum.com/t31778.html

TJ

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum