Главная страница


ru.algorithms

 
 - RU.ALGORITHMS ----------------------------------------------------------------
 From : Viktor Karev                         2:5020/400     11 Oct 2001  20:17:36
 To : Vadim Goncharov
 Subject : Re: DES-3
 -------------------------------------------------------------------------------- 
 
 Окончание.
 
 var
  NewKey: string;
 
 procedure SetNewKey;
 begin
  if PKey+7<=Len then
  begin
   NewKey:=Copy(Key,Pkey,8);
   inc(Pkey,8);
  end
  else
  begin
   NewKey:=Copy(Key,PKey,8)+Copy(Key,1,PKey+7-Len);
   inc(PKey,8-Len);
  end;
  InitKey(PDataBlock(@NewKey[1])^);
 end;
 
 procedure SetKey(S: string);
 begin
  Key:=S;
  Len:=length(S);
  if Len<8 then
   Halt(1);
  PKey:=1;
  SetNewKey;
 end;
 
 procedure Encode(InBlock: TDataBlock; var OutBlock: TDataBlock);
 begin
  R:=KE;
  DoDes(InBlock,OutBlock);
 end;
 
 procedure Decode(InBlock: TDataBlock; var OutBlock: TDataBlock);
 begin
  R:=KD;
  DoDes(InBlock,OutBlock);
 end;
 
 procedure EncodeText(InS: string; var OutS: string);
 var
  i,j,l: integer;
  S: TDataBlock;
 begin
  i:=1;
  l:=Length(InS);
  OutS[0]:=InS[0];
  while i*8-7<=l do
  begin
   Move(InS[i*8-7],S,8);
   if i*8>L then
    for j:=(l mod 8)+1 to 8 do
     S[j]:=0;
   Encode(S,S);
   Move(S,OutS[i*8-7],8);
   OutS[0]:=char(i*8);
   inc(i);
   SetNewKey;
  end;
 end;
 
 procedure DecodeText(InS: string; var OutS: string);
 var
  i,j,l: integer;
  S: TDataBlock;
 begin
  i:=1;
  l:=Length(InS);
  OutS[0]:=InS[0];
  while i*8-7<=l do
  begin
   Move(InS[i*8-7],S,8);
   if i*8>L then
    for j:=(l mod 8)+1 to 8 do
     S[j]:=0;
   Decode(S,S);
   if i*8<=L then
    Move(S,OutS[i*8-7],8)
   else
    Move(S,OutS[i*8-7],L-(i-1)*8);
   inc(i);
   SetNewKey;
  end;
 end;
 
 begin
  InitDes;
 end.
 --- ifmail v.2.15dev5
  * Origin: Black Jack House (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 DES   Vadim Goncharov   24 Sep 2001 21:09:27 
 Re: DES   Vinokurov Andrey   25 Sep 2001 13:36:41 
 Re^2: DES   Vadim Goncharov   02 Oct 2001 19:48:01 
 Re: DES   Vinokurov Andrey   03 Oct 2001 19:08:15 
 Re^2: DES   Vadim Goncharov   10 Oct 2001 22:19:24 
 Re: DES   Viktor Karev   11 Oct 2001 20:15:33 
 Re: DES-2   Viktor Karev   11 Oct 2001 20:15:35 
 Re: DES-3   Viktor Karev   11 Oct 2001 20:17:36 
Архивное /ru.algorithms/657789c6917a.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional