DoubleDutch wrote:Have you a link to the solution you found?
I forget the link ! but if you want the code ...
Code: Select all
Procedure.l RC4Mem(Mem.l, memLen.l, key.s) ;rückgabe = adresse des vrschlüsselten speichers
; RC4 Verschlüsselung >30MB/s
Protected i.l, t.l, x.l, j.l, temp.l, y.l, l.l, *Sp.Long, *KeyP.Byte, *Memm.Byte
If key<>""
Dim S.l(255)
Dim K.l(255)
i = 0 : j = 0 : t = 0 : x = 0
temp = 0 : y = 0
j = 1
l.l = Len(key)
*Sp = @S()
*KeyP = @key
For i = 0 To 255
*Sp\l = i
*Sp + 4
If *KeyP\b = 0
*KeyP = @key
EndIf
K(i) = *KeyP\b
*KeyP + 1
Next i
j = 0
For i = 0 To 255
j = (j + S(i) + K(i)) & 255
temp = S(i)
S(i) = S(j)
S(j) = temp
Next i
i = 0
j = 0
*Memm = Mem
For x = 0 To memLen-1
i = (i + 1) & 255
j = (j + S(i)) & 255
;temp = S(i)
;S(i) = S(j)
;S(j) = temp
Swap S(i), S(j)
t = (S(i) + (S(j) & 255)) & 255
y = S(t)
*Memm\b ! y
*Memm + 1
Next
ProcedureReturn Mem
EndIf
ProcedureReturn 0
EndProcedure
ProcedureDLL.s CryptText(string.s, Key.s)
Protected strlen.l, enc.s, *codetmem
strlen = StringByteLength(string)
enc.s = Space(Int(strlen*1.35))
*codetmem = RC4Mem(@string, strlen, key)
Base64Encoder(*codetmem, strlen, @enc, strlen*1.35)
ProcedureReturn enc
EndProcedure
ProcedureDLL.s DeCryptText(string.s, Key.s)
Protected strlen.l, dec.s, decoutp.s, str2len.l, *decodetmem
strlen = StringByteLength(string)
dec.s = Space(Int(strlen*0.75))
str2len.l = Base64Decoder(@string, strlen, @dec, strlen*0.75)
*decodetmem = RC4Mem(@dec, str2len, key)
decoutp.s = PeekS(*decodetmem, str2len)
ProcedureReturn decoutp.s
EndProcedure