1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| function EncodeString(TextString, pwd: string):string; var Zeile,pwdZeile:string; i,Anzahl,Zahl,Zufall,pwdZahl:Integer; begin pwdZahl:=GetCheckSum(pwd); Randomize; Zufall:=Random(223)+32; pwdZeile:=''; Result:=''; Anzahl:=Length(TextString); while Length(pwdZeile)<Anzahl do pwdZeile:=pwdZeile+pwd; for i:=1 to Anzahl do begin Zahl:=Ord(TextString[i])+Ord(pwdZeile[i])+pwdZahl; while Zahl>255 do Zahl:=Zahl-223; Zeile:=Zeile+Chr(Zahl); end; Zeile:=Zeile+Chr(Zufall); pwdZeile:=pwdZeile+pwd; Anzahl:=Length(Zeile)-1; for i:=Anzahl downto 1 do begin Zahl:=Ord(Zeile[i])+Ord(pwdZeile[i])+Ord(Zeile[i+1]); while Zahl>255 do Zahl:=Zahl-223; Zeile[i]:=Chr(Zahl); end; Result:=Zeile; end;
function DecodeString(TextString, pwd: string):string; var Zeile,pwdZeile:string; i,Anzahl,Zahl,pwdZahl:Integer; begin pwdZahl:=GetCheckSum(pwd); pwdZeile:=''; Result:=''; Anzahl:=Length(TextString); while Length(pwdZeile)<Anzahl do pwdZeile:=pwdZeile+pwd; Dec(Anzahl); Zeile:=''; for i:=1 to Anzahl do begin Zahl:=Ord(TextString[i])-Ord(pwdZeile[i])-Ord(TextString[i+1]); while Zahl<32 do Zahl:=Zahl+223; Zeile:=Zeile+Chr(Zahl); end; Zeile:=LeftStr(Zeile,Anzahl); for i:=1 to Anzahl do begin Zahl:=Ord(Zeile[i])-Ord(pwdZeile[i])-pwdZahl; while Zahl<32 do Zahl:=Zahl+223; Zeile[i]:=Chr(Zahl); end; Result:=Zeile; end;
function GetCheckSum(TextString: string): LongInt; var i:Integer; begin Result:=0; for i:=1 to Length(TextString) do Result:=Result+Ord(TextString[i]) end; |