Re: xor funktioniert nicht
Zitat:
Alles unter naja sagen wir 5 Sekunden braucht nur eine Sanduhr. Sollte die Datenmenge so groß werden, daß man mehr als 3 Sekunden braucht, dann kann man immer noch die Funktion auf Zeigerarithmetik umbauen...
Delphi-Quellcode:
// 250 MB => ~ 1 Sekunde
function StringXorCrypt(const text, key:string):string; var i, j, keylen : Integer; ptext, presult, pkey : PChar; begin SetLength(Result, length(text)); j := 1; keylen := Length(key); ptext := PChar(text); presult := PChar(Result); pkey := PChar(key); for i := 1 to Length(text) do begin presult^ := chr(ord(ptext^) xor ord(pkey^)); inc(presult); Inc(ptext); Inc(pkey); Inc(j); if j > keylen then begin j := 1; pkey := PChar(key); end; end; end; |
Re: xor funktioniert nicht
falls es noch schneller sein muß...
Delphi-Quellcode:
500 MB + 9 Byte-Key
Function StringXorCrypt(Const Text, Key: AnsiString): AnsiString;
Var pText, pTextEnd, pKey, pKeyEnd, pResult: PAnsiChar; Begin SetLength(Result, Length(Text)); pText := PAnsiChar(Text); pTextEnd := PAnsiChar(Text) + Length(Text); pKey := PAnsiChar(Key); pKeyEnd := PAnsiChar(Key) + Length(Key); pResult := PAnsiChar(Result); While pText < pTextEnd do Begin pResult^ := Chr(Ord(pText^) xor Ord(pKey^)); Inc(pText); Inc(pResult); Inc(pKey); If pKey >= pKeyEnd Then pKey := PAnsiChar(Key); End; End; shmia = 2,3 sec himi = 1,2 sec (auf meiner 2,7 GHz-Krücke) und wer Lust hat, bekommst bestimmt immernoch mehr raus, aber ob das soooooo nötig ist? also Beides schon schnell genug und ob man da wirklich noch 'ne ProgressBar braucht :shock: , selbst wenn man vermutlich nicht oft solche Datenmengen verschlüsseln wird :roll: PS: das AnsiString <> String hat nix mit dem Tempo zu tun, sondern nur mit der Kompatibilität zu D2009+ |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz