On the bottom of the referenced thread, Dare2 posted a nice encryption code that is actually quite wonderful. A copy of it is found below:
Code: Select all
Procedure.s selfE(src.s,en.l)
  k1=Len(src)
  If k1>0
    *p=@src
    k2=PeekB(*p) & $FF
    r=k1 ! k2
    If r<>0 : PokeB(*p,r) : EndIf
    For i=2 To Len(src)
      *p+1
      If en : k1=PeekB(*p-1) & $FF : Else : k1=k2 : EndIf
      k2=PeekB(*p)
      r=k1 ! k2
      If r<>0 : PokeB(*p,r) : EndIf
    Next
  EndIf
  ProcedureReturn src
EndProcedure
w.s="Wooo! Hooo! This is self encrypting"
x.s=selfE(w,#True)
y.s=selfE(x,#False)
Debug w
Debug x
Debug y
The following is what I have so far in VB6 ...
Code: Select all
Option Explicit
'\\ API declarations...
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Long, ByVal Length As Long)
Private Declare Sub CopyMemoryByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Byte, Source As Long, ByVal Length As Long)
Private Declare Sub CopyMemoryFromByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Byte, ByVal Length As Long)
Public Function SelfE(SRC As String, EN As Long) As String
    Dim ptrP    As Long
    Dim I       As Long
    Dim K1      As Byte
    Dim K2      As Long
    Dim R       As Long
    
    K1 = LenB(SRC)
    If K1 > 0 Then
        ptrP = VarPtr(ByVal SRC)
        K2 = PeekByte(VarPtr(ptrP)) & &HFF
    
        R = K1 Or K2
       
        If R <> 0 Then
            Call PokeByte(VarPtr(ptrP), R)
        End If
        For I = 2 To LenB(SRC)
            ptrP = ptrP + 1
    
            If EN = True Then
                K1 = PeekByte(VarPtr(ptrP) - 1) & &HFF
            Else
                K1 = K2
            End If
            
            K2 = PeekByte(VarPtr(ptrP))
            R = K1 Or K2
            
            If R <> 0 Then
                Call PokeByte(VarPtr(ptrP), R)
            End If
        Next I
    End If
    SelfE = SRC
End Function
Public Function Peek(Address As Long) As Long
    Call CopyMemory(Peek, ByVal Address, Len(Address))
End Function
Public Function PeekByte(Address As Long) As Byte
    Call CopyMemoryByte(PeekByte, ByVal Address, Len(PeekByte))
End Function
Public Function Poke(Address As Long, Value As Long)
    CopyMemory ByVal Address, Value, LenB(Value)
End Function
Public Function PokeByte(Address As Long, Value As Byte)
    CopyMemoryFromByte ByVal Address, Value, LenB(Value)
End Function
Any clues?


 thanks for the info about exclusive or, I'll see if I can find the VB Equivilent.
 thanks for the info about exclusive or, I'll see if I can find the VB Equivilent.

