Dear Priyatna Harun,

Thanks very much.

Hasanul Arifin

-----Original Message-----
From: Priyatna Harun [mailto:[EMAIL PROTECTED]] 
Sent: 22 Nopember 2002 8:59
To: [EMAIL PROTECTED]
Subject: RE: [Delphindo] Encryption / Decryption Method...

At 01:02 19/11/2002 +0700, you wrote:

>Metode apa yah yang sebaiknya saya gunakan untuk mengenkripsi / dekripsi
>sebuah string yang terdiri dari alpha-numerik (e.g. 123bhnbj456s3), namun
>hasil enkripsinya juga merupakan alpha-numerik.

>***
>Gue tidak begitu pasti and lupa - lupa ingat nama menthod
>encription/decriptionnya. tapi kalo tidak salah you bisa coba gunakan
>uuencode/uudecode.

Saya juga biasa pake teknik itu. Hanya tabel karakternya aja yang
diubah pake tabel kita sendiri (65 karakter).
Keuntungannya: bisa dipake untuk enskripsi sembarang data (binary/text).

Ini saya adaptasi dari Synapse:

unit EncDec;

interface

   function EncodeString(Str: string): string;
   function DecodeString(Str: string): string;

implementation

const

   TheTable =
     '~!@#$%^&*()_+|\;-0987654321`?><MNBVCXZzxcvbnm,./}{[]qwertyuiopasd';
   //Nih tabel karakternya, ganti aja sama kita, pokoknya 65 karakter ASCII,
   //jangan ada karakter yang sama.

function Encode3to4(const Value, Table: string): string;
var
   c: Byte;
   n, l: Integer;
   Count: Integer;
   DOut: array[0..3] of Byte;
begin
   setlength(Result, ((Length(Value) + 2) div 3) * 4);
   l := 1;
   Count := 1;
   while Count <= Length(Value) do
   begin
     c := Ord(Value[Count]);
     Inc(Count);
     DOut[0] := (c and $FC) shr 2;
     DOut[1] := (c and $03) shl 4;
     if Count <= Length(Value) then
     begin
       c := Ord(Value[Count]);
       Inc(Count);
       DOut[1] := DOut[1] + (c and $F0) shr 4;
       DOut[2] := (c and $0F) shl 2;
       if Count <= Length(Value) then
       begin
         c := Ord(Value[Count]);
         Inc(Count);
         DOut[2] := DOut[2] + (c and $C0) shr 6;
         DOut[3] := (c and $3F);
       end
       else
       begin
         DOut[3] := $40;
       end;
     end
     else
     begin
       DOut[2] := $40;
       DOut[3] := $40;
     end;
     for n := 0 to 3 do
     begin
       Result[l] := Table[DOut[n] + 1];
       Inc(l);
     end;
   end;
end;

function Decode4to3(const Value, Table: string): string;
var
   x, y, n, l: Integer;
   d: array[0..3] of Byte;
begin
   SetLength(Result, Length(Value));
   x := 1;
   l := 1;
   while x < Length(Value) do
   begin
     for n := 0 to 3 do
     begin
       if x > Length(Value) then
         d[n] := 64
       else
       begin
         y := Pos(Value[x], Table);
         if y < 1 then
           y := 1;
         d[n] := y - 1;
       end;
       Inc(x);
     end;
     Result[l] := Char((D[0] and $3F) shl 2 + (D[1] and $30) shr 4);
     Inc(l);
     if d[2] <> 64 then
     begin
       Result[l] := Char((D[1] and $0F) shl 4 + (D[2] and $3C) shr 2);
       Inc(l);
       if d[3] <> 64 then
       begin
         Result[l] := Char((D[2] and $03) shl 6 + (D[3] and $3F));
         Inc(l);
       end;
     end;
   end;
   Dec(l);
   SetLength(Result, l);
end;


function EncodeString(Str: string): string;
begin
   Result := Encode3To4(Str, TheTable);
end;

function DecodeString(Str: string): string;
begin
   Result := Decode4To3(Str, TheTable);
end;

end.




Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED] 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED] 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


Kirim email ke