Mega Code Archive

 
Categories / Delphi / Examples
 

Encrypttext

SIMPLE ENCRYPTION USING XOR [needs checking] ************************************************************ function Encrypt(const S: String; Key: Word): String; var I: byte; begin Result[0] := S[0]; //******* for I := 1 to Length(S) do begin Result[I] := char(byte(S[I]) xor (Key shr 8)); Key := (byte(Result[I]) + Key) * C1 + C2; end; end; function Decrypt(const S: String; Key: Word): String; var I: byte; temp : string; begin temp[0] := S[0]; for I := 1 to Length(S) do begin temp[I] := char(byte(S[I]) xor (Key shr 8)); Key := (byte(S[I]) + Key) * C1 + C2; end;{for} result := temp; end; possibly replace the asterisked line above with this line: SetLength(Result, Length(S)); Since "If you leave that out, you will get problems. Without it, your Result string has either a random length or a length of 0 (I don't remember which right now). So your Result[I] lines will try to change a non-existent character and raise an error". ************************************************************ see also code in Richards Writer's Toolkit ************************************************************ At 10:28 12/09/00 +0000, you wrote: >Hi! > >Could anyone tell, where to find a component for encrypting/decrypting text. >Please HELP!... Hi Tomislav, I recently spent hours looking around the 'Net and evaluating different cryptography components. There is an excellent collection at http://www.efg2.com/Lab/Library/Delphi/MathFunctions/Cryptography.htm I found the "Delphi Encryption Compendium" listed on this page to be the best collection of tools for what I wanted. It took a little painful work to get them up and running, but it was well worth the effort. hth, Chris. ===================================================== Intelligent Irrigation Systems Ph: 03 9739 4422 3/5 Clarke St Fax: 03 9739 4455 Lilydale Vic 3140 Mob: 0419 355 565 Australia http://www.cohort.com.au ===================================================== **************************************************************************************** > Could anyone tell, where to find a component for encrypting/decrypting text. > Please HELP!... Try http://www.scramdisk.clara.net HTH Martin Jambor ------------------------ Martin Jambor Independent Developer JamborM@iname.com **************************************************************** > Try HyperString http://efd.home.mindspring.com/tools.htm Glenn Crouch mailto:glenn@esbconsult.com.au ICQ:36017076 ESB Consultancy, http://www.esbconsult.com.au Home of ESBPCS, ESBStats, ESBPDF Analysis & ESBCalc Kalgoorlie-Boulder, Western Australia (TeamND, TeamOE, Addict Support, eLists.org Management) **************************************************************** An excellent, free encryption library: DCPcrypt: http://www.scramdisk.clara.net/ (click on the Delphi link) **************************************************************** Check http://www.multimania.com/sirius29/algos.html