Advertisement
Guest User

XOR Encryption Source

a guest
Apr 7th, 2011
4,506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Function Encrypt(ByVal CodeKey As String, ByVal DataIn As String) As String
  2.   Dim lonDataPtr As Long
  3.   Dim strDataOut As String
  4.   Dim temp As Integer
  5.   Dim tempstring As String
  6.   Dim intXOrValue1 As Integer
  7.   Dim intXOrValue2 As Integer
  8.   For lonDataPtr = 1 To Len(DataIn)
  9.     intXOrValue1 = Asc(Mid$(DataIn, lonDataPtr, 1))
  10.     intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
  11.  
  12.     temp = (intXOrValue1 Xor intXOrValue2)
  13.     tempstring = Hex(temp)
  14.     If Len(tempstring) = 1 Then tempstring = "0" & tempstring
  15.     strDataOut = strDataOut + tempstring
  16.   Next lonDataPtr
  17.   Return strDataOut
  18.     End Function
  19.  
  20.     Public Function Decrypt(ByVal CodeKey As String, ByVal DataIn As String) As String
  21.   Dim lonDataPtr As Long
  22.   Dim strDataOut As String
  23.   Dim intXOrValue1 As Integer
  24.   Dim intXOrValue2 As Integer
  25.  
  26.   For lonDataPtr = 1 To (Len(DataIn) / 2)
  27.     intXOrValue1 = Val("&H" & (Mid$(DataIn, (2 * lonDataPtr) - 1, 2)))
  28.     intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
  29.  
  30.     strDataOut = strDataOut + Chr(intXOrValue1 Xor intXOrValue2)
  31.   Next lonDataPtr
  32.   Return strDataOut
  33.     End Function
  34. [u]stub :
  35. [/u]
  36.  
  37. Public Function XOR(ByVal CodeKey As String, ByVal DataIn As String) As String
  38.   Dim lonDataPtr As Long
  39.   Dim strDataOut As String
  40.   Dim intXOrValue1 As Integer
  41.   Dim intXOrValue2 As Integer
  42.  
  43.   For lonDataPtr = 1 To (Len(DataIn) / 2)
  44.     intXOrValue1 = Val("&H" & (Mid$(DataIn, (2 * lonDataPtr) - 1, 2)))
  45.     intXOrValue2 = Asc(Mid$(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
  46.  
  47.     strDataOut = strDataOut + Chr(intXOrValue1 Xor intXOrValue2)
  48.   Next lonDataPtr
  49.   xEncryption = strDataOut
  50.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement