unless you are working with the Pentagon .
for other case ,you can try this super easy , super fast tiny encryption method for some good medium security .
Code: Select all
Structure key
k.l[0]
EndStructure
DataSection
key:
Data.i $ABCDEFAB,$9876BCDE,$dcbaafe0
EndDataSection
Global *key.key
*key = ?key
Procedure enc(buf , size)
n=size%4
IF n
*n=ReAllocateMemory(buf,size + n)
ENDIF
IF Not *n
*n=buf
ENDIF
b=size/4-1
For i=0 To 2
For p=0 To b
j=*n+p<<2
PokeL(j,PeekL(j)!*key\k[i])
Next
Next
IF n
*o=ReAllocateMemory(*n,size)
ENDIF
IF Not *o
*o=*n
ENDIF
ProcedureReturn *o
EndProcedure
Procedure dec(buf,size)
n=size%4
IF n
*n=ReAllocateMemory(buf,size + n)
ENDIF
IF Not *n
*n=buf
ENDIF
b=size/4-1
For i=2 To 0 Step -1
For p=0 To b
j=*n+p<<2
PokeL(j,PeekL(j)!*key\k[i])
Next
Next
IF n
*o=ReAllocateMemory(*n,size)
ENDIF
IF Not *o
*o=*n
ENDIF
ProcedureReturn *o
EndProcedure
; Example use:
A$="The quick brown fox jumps over the lazy dog 12 times a day"
L=Len(A$)<<1+2
*u=AllocateMemory(200)
PokeS(*u,A$)
Debug PeekS(*u)
Encrypt = enc(*u, L )
Debug PeekS( Encrypt)
Decrypt = dec(Encrypt, L)
Debug PeekS(Decrypt,L)
you could even make it smaller by using only one procedure to encrypt and decrypt , they are same actually.