AuthorMessage
Meka][Meka
Unstopable
Posts: 700

just an example.. read the code header.... ultra fast locktokey
Code:

//optimal for delphi 7
function DC_Key(const l: string): string;
  //function written by Meka][Meka.
  //an example of creating a superior function in speed...
  //this code may not be used in any other forum or on any otherwebsite without permission.
var
  i   : Integer;
  a   : Byte;
  c,s : String;
begin
  Result := '';
  for i := 2 to Length(l) do
    Insert(Chr(Ord(l[i]) xor Ord(l[i-1])), Result, i-1);
  Insert(Chr(Ord(l[1]) xor Ord(l[Length(l)]) xor Ord(l[Length(l)-1]) xor 5), Result, 1);
  for i := 1 to Length(Result) do begin
    a := Ord(Result[i]);
    Result[i] := Chr(((a shl 4) and 240) or ((a shr 4) and 15));
  end;
  Insert(Copy(Result, 1, Length(Result)), s, 1);
  Result := '';
  for i := 1 to Length(s) do begin
    c := s[i];
    a := Ord(c[1]);
    case a of
      0: c := '/%DCN000%/';
      5: c := '/%DCN005%/';
      36: c := '/%DCN036%/';
      96: c := '/%DCN096%/';
      124: c := '/%DCN124%/';
      126: c := '/%DCN126%/';
    end;
    Insert(c, Result, i);
  end;
end;

usage:
Code:

var
  s: string;
begin
  s := DC_Key('BLAHBLAHTESTABCABC_EXTENDPROC');

njoy