Hi,
this is a random based encrypter, for symetric cryption.
Code: Select all
Global kor$
Procedure.s Crypt2(encrypt_text$,Passwort$, type)
kor$="I"
out$ = "":Seed=0
lentext = Len(encrypt_text$)
lenpass2=Len(Passwort$)
Dim p1array(lentext+1)
If lentext > 0 And lenpass2 > 0
For p = 1 To lentext
p1array(p) = Asc(Mid(encrypt_text$, p, 1))
Next
For Schleife=1 To lenpass2
z=0
Seed=Seed+Asc(Mid(Passwort$,Schleife,1))*Schleife
RandomSeed(Seed)
For p=1 To lentext
While z<Seed
z=z+1
Random(255)
Wend
p1array(p)=p1array(p)+Random(255)
Next
Next
For p=1 To lentext
out2$=Chr(p1array(p))
If out2$=Chr(0)
out2$=Chr(1)
kor$=kor$+Str(p)+"I"
EndIf
out$=out$+out2$
Next
EndIf
ProcedureReturn(out$)
EndProcedure
Procedure.s EnCrypt2(encrypt_text$,Passwort$, type)
out$ = "":Seed=0
lentext = Len(encrypt_text$)
lenpass2=Len(Passwort$)
Dim p1array(lentext)
For p=1 To lentext
p1array(p)=Asc(Mid(encrypt_text$,p,1))
If FindString(kor$,"I"+Str(p)+"I",1)
p1array(p)=0
EndIf
Next
If lentext > 0 And lenpass2 > 0
For Schleife=1 To lenpass2
z=0
Seed=Seed+Asc(Mid(Passwort$,Schleife,1))*Schleife
RandomSeed(Seed)
For p = 1 To lentext
While z<Seed
z=z+1
Random(255)
Wend
p1array(p)=p1array(p)-Random(255)
Next
Next
For p=1 To lentext
out$=out$+Chr(p1array(p))
Next
EndIf
ProcedureReturn(out$)
EndProcedure
Passwort$ = InputRequester("Encrypter", "Please type a password", "")
text$ = InputRequester("Encrypter", "Please type a text", "")
result$ = Crypt2(text$, Passwort$, 0)
MessageRequester("Result", result$, 0)
result1$ = EnCrypt2(result$, Passwort$, 1)
MessageRequester("Result", result1$, 0)
; by Johannes Rosenberg
Johannes