Um, unless I'm mistaken, this is a pretty basic cypher - are you after
encrypting something that NEEDS to stay crypted, or just scrambling
something so a luser can't get at it? if its the latter, this should be
fine, but a cryptographer work his salt should be able to go thru this in
about 2 seconds flat. Something like MD5 or RC4 are _proven_ "secure" by
years of testing etc.

Another thing to look at could be Bill Raike's library - not sure of the
URL, but's he's over here in NZ somewhere :)

Nic.

----- Original Message -----
From: "Ross Levis" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Wednesday, September 26, 2001 2:53 PM
Subject: RE: [DUG]: String Encryption routine


> Hi Phil
>
> This looks useful.  Can I assume it decrypts as well by passing the
Encrypt
> param as False?
>
> Cheers,
> Ross.
>
> Phil Scadden wrote:
> > here is my favourite, very simple string to hex gobbledegooker.
> >
> > Function Encrypt (Src:String; Key:String; Encrypt : Boolean):string;
> > var
> >    idx         :integer;
> >    KeyLen      :Integer;
> >    KeyPos      :Integer;
> >    offset      :Integer;
> >    dest        :string;
> >    SrcPos      :Integer;
> >    SrcAsc      :Integer;
> >    TmpSrcAsc   :Integer;
> >    Range       :Integer;
> >
> > begin
> >      KeyLen:=Length(Key);
> >      if KeyLen = 0 then key:='235jhsf9msf;&#@*#';
> >      KeyPos:=0;
> >      SrcAsc:=0;
> >      Range:=256;
> >      if Encrypt then
> >      begin
> >           Randomize;
> >           offset:=Random(Range);
> >           dest:=format('%1.2x',[offset]);
> >           for SrcPos := 1 to Length(Src) do
> >           begin
> >                SrcAsc:=(Ord(Src[SrcPos]) + offset) MOD 255;
> >                if KeyPos < KeyLen then KeyPos:= KeyPos + 1
> > else KeyPos:=1;
> >                SrcAsc:= SrcAsc xor Ord(Key[KeyPos]);
> >                dest:=dest + format('%1.2x',[SrcAsc]);
> >                offset:=SrcAsc;
> >           end;
> >      end
> >      else
> >      begin
> >           offset:=StrToInt('$'+ copy(src,1,2));
> >           SrcPos:=3;
> >           repeat
> >                 SrcAsc:=StrToInt('$'+ copy(src,SrcPos,2));
> >                 if KeyPos < KeyLen Then KeyPos := KeyPos + 1
> > else KeyPos := 1;
> >                 TmpSrcAsc := SrcAsc xor Ord(Key[KeyPos]);
> >                 if TmpSrcAsc <= offset then
> >                      TmpSrcAsc := 255 + TmpSrcAsc - offset
> >                 else
> >                      TmpSrcAsc := TmpSrcAsc - offset;
> >                 dest := dest + chr(TmpSrcAsc);
> >                 offset:=srcAsc;
> >                 SrcPos:=SrcPos + 2;
> >           until SrcPos >= Length(Src);
> >      end;
> >      Result:=Dest;
> > end;
> >
> > ----------------------------------------------------------
> > Phil Scadden, Institute of Geological and Nuclear Sciences
> > 41 Bell Rd South, PO Box 30368, Lower Hutt, New Zealand
> > Ph +64 4 5704821, fax +64 4 5704603
> >
> > --------------------------------------------------------------
> > -------------
> >     New Zealand Delphi Users group - Delphi List -
> > [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> >
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to