_uc_crypto.pas

unit _uc_crypto;

interface
   uses classes,Sysutils;




Const
_CRYPT_BYTES_FR_SMYA = 'Ú!~…ˆ‰‰~Ž‹èÐèߌ†¬‚…èÙÞ×ÝÚ×—ß'; // LKATEB_SMIYA
_CRYPT_BYTES_FR_DRSA = '‚Œö®¬€¯¬…‚Ö‹~~ö‹';           // LKATEB_eDRISSA

_Base64Chars         = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';




Type

    TCrypto = class
    public
    class function _BarzaToon(s:string):string;  // encode
    class function _SimSim(s:string):string;    // decode

    class function _EncodeTheHEXString(s:string):String;
    class function _DeCodeTheHEXString(s:string):String;

    class function _Base64Encode(s:String): String;
    class function _Base64Decode(s:String): String;

    class function bndaka(s:string):string;
    class function kozkozo(s:string):string;
    end;






implementation

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class function TCrypto._BarzaToon(s:string):string;
var
i:integer;
p:byte;
begin



for i:=1 to length(s) do
begin

p:=ord(s[i]);

 case p of
     1..25 : s[i]:=chr(p+175);   //a--h
    26..50 : s[i]:=chr(p+200 );  //b--j
    51..75 : s[i]:=chr(p+150);   //c--i
    76..100: s[i]:=chr(p+75);    //d--g
   101..125: s[i]:=chr(p+25);    //e--f

   126..150: s[i]:=chr(p-25);    //f--e
   151..175: s[i]:=chr(p-75);    //g--d
   176..200: s[i]:=chr(p-175);   //h--a
   201..225: s[i]:=chr(p-150);   //i--c
   226..250: s[i]:=chr(p-200);   //j--b
 end;

end;


result:=s;

end;

//------------------------------------------------------------------------------
class function TCrypto._SimSim(s:string):string;
var
i:integer;
p:byte;
tmp_str:string;
begin

tmp_str:=s;

for i:=1 to length(tmp_str) do
begin
p:=ord(tmp_str[i]);

 case p of
    176..200 : tmp_str[i]:=chr(p-175);   //-h  a-
    226..250 : tmp_str[i]:=chr(p-200 );  //--j   b
    201..225 : tmp_str[i]:=chr(p-150);   //-i   c-
    151..175 : tmp_str[i]:=chr(p-75);    //-g     d-
    126..150 : tmp_str[i]:=chr(p-25);    //-f    e-
   
    101..125 : tmp_str[i]:=chr(p+25);    //--e   f
     76..100 : tmp_str[i]:=chr(p+75);    //-d   g-
      1..25  : tmp_str[i]:=chr(p+175);   //--a    h
     51..75  : tmp_str[i]:=chr(p+150);   //--c    i
     26..50  : tmp_str[i]:=chr(p+200);   //--b    j
 end;
end;


result:=tmp_str;

end;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class function TCrypto._EnCodeTheHEXString(s:string):String;
var
i:integer;
begin

  for i:=1 to length(s) do
  begin
  Result:=Result+IntToHex(Ord(s[i]),2)+'.';
  end;

end;

//------------------------------------------------------------------------------
class function TCrypto._DeCodeTheHEXString(s:string):String;
var
i:integer;
mx:TStringList;
e:string[2];
begin


     mx:=TStringList.Create;
     try

       mx.Text:=StringReplace(s,'.',#13#10,[rfReplaceAll]);
       for i:=0 to mx.Count-1 do
       begin
       e:=mx[i];
       Result:=Result+Chr(StrToIntDef('$'+e[1]+e[2],0));
       end;

     finally mx.Free; end;

end;

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class function TCrypto._Base64Encode(s:String): String;
var
i,a,x,b: Integer;
begin


Result := '';

a := 0;
b := 0;

   for i := 1 to Length(S) do
   begin
   x := Ord(s[i]);
   b := b * 256 + x;
   a := a + 8;

      while a >= 6 do
      begin
      a := a - 6;
      x := b div (1 shl a);
      b := b mod (1 shl a);
      Result := Result + _Base64Chars[x + 1];
      end;

   end;



   if (a > 0) then
   begin
   x := b shl (6 - a);
   Result := Result + _Base64Chars[x + 1];
   end;

   while Length(Result) mod 4 > 0 do
   begin
   Result := Result + '=';
   end;


end;

(*

Server_Started_Listening_on_Port_80 ...
Client_Connected : 192.168.0.1 [2mya58zgaqtsb6e]
_READING_:


GET http://www.netvampire.com:80/ftp/netvampire.zip HTTP/1.0
Proxy-Connection: Close
Proxy-Authorization: Basic YWFhOmNjYw==
Host: www.netvampire.com
Accept: */*
Pragma: no-cache
Cache-Control: no-cache
Referer: http://www.netvampire.com/ftp/
User-Agent: Mozilla/4.04 [en] (Win95; I ;Nav)


.Server_Off

*)



//------------------------------------------------------------------------------

class function TCrypto._Base64Decode(s:String): String;
var
i,a,x,b: Integer;
begin

Result := '';
   a := 0;
   b := 0;
   for i := 1 to Length(S) do
   begin
   x := Pos(s[i], _Base64Chars) - 1;
   if x >= 0 then
   begin
   b := b * 64 + x;
   a := a + 6;
   if a >= 8 then
   begin
   a := a - 8;
   x := b shr a;
   b := b mod (1 shl a);
   x := x mod 256;
   Result := Result + chr(x);
   end;
   end
   else
   Exit;
   end;

end;

//------------------------------------------------------------------------------
class function TCrypto.bndaka(s:string):string;
var
i:integer;
p:byte;
begin

for i:=1 to length(s) do
begin

p:=ord(s[i]);

 case p of
     1..25 : s[i]:=chr(p+200);   //a--i .
    26..50 : s[i]:=chr(p+100);  //b--f  .
    51..75 : s[i]:=chr(p+125);   //c--h .
    76..100: s[i]:=chr(p+150);    //d--j .
   101..125: s[i]:=chr(p+50);    //e--g .

   126..150: s[i]:=chr(p-100);    //f--b .
   151..175: s[i]:=chr(p-50);    //g--e  .
   176..200: s[i]:=chr(p-125);   //h--c  .
   201..225: s[i]:=chr(p-200);   //i--a .
   226..250: s[i]:=chr(p-150);    //j--d .
 end;

end;


result:=s;

end;

//------------------------------------------------------------------------------
class function TCrypto.kozkozo(s:string):string;
var
i:integer;
p:byte;
begin

for i:=1 to length(s) do
begin

p:=ord(s[i]);

 case p of
    226..250 : s[i]:=chr(p-150 );  // j.d ..
    201..225 : s[i]:=chr(p-200);   // i.a..
    176..200 : s[i]:=chr(p-125);   // h.c..
    151..175 : s[i]:=chr(p-50);    // g.e..
    126..150 : s[i]:=chr(p-100);    // f.b..

    101..125 : s[i]:=chr(p+50);    // e.g..
     76..100 : s[i]:=chr(p+150);    // d.j ..
     51..75  : s[i]:=chr(p+125);   // c.h ..
     26..50  : s[i]:=chr(p+100);    // b .f..
      1..25  : s[i]:=chr(p+200);   // a.i
 end;

end;


result:=s;

end;



end.





../delphi71code/exosee-code-source/uc_crypto-pas..