» , » DES -


DES -

| 3 3
valign=top>7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 13 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1

>R(0) = 11111111111111110101001101110000

>E(R(0)) = 011111111111111111111110101010100110101110100001

'R(i)K(i+1)XOR

>R(0)K(1)xor = 001011111101001101010010111111010100000101100011

> P.S( 6 4 )

>S(1) = 2 = 0010S(2) = 14 = 1110S(3) = 9 = 1001S(4) = 2 = 0010

>S(5) = 3 = 0011S(6) = 3 = 0011S(7) = 11 = 1011S(8) = 1 = 0001

> (>S1..S8) = 00101110100100100011001110110001

P

16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10
2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25

= 01100110011010000010111110010001

>L(i)R(i+1)XOR

>L(0) = 11111111000011010001010000000000

R(0) = 01100110011010000010111110010001

>XORR(1)=10011001011001010011101110010001

>L(1) =R(0)

' , . ֳ 䳿 16 , 16 >DES.

>L(1) = 11111111111111110101001101110000

>R(1) = 10011001011001010011101110010001

>E(R1) = 110011110010101100001010100111110111110010100011

>R(1)XORK(2) = 100111111000011110101110110011111101111111100100

>S(1..8) = 00101001100011011111100011000100

>P = 10110001000111000101001111100001

>R(1)XORL(1) = 01001110111000110000000010010001 =R(2)

>L(2) =R(1) = 10011001011001010011101110010001

>E(R2) = 101001011101011100000110100000000001010010100010

>R(2)XORK(3) = 011101010111101100100000011101101001000000101110

>S(1..8) = 00111010001110101000100101000010

>P = 01010101010110100010001001000110

>R(2)XORL(2) = 11001100001111110001100111010111 =R(3)

>L(3) =R(2) = 01001110111000110000000010010001

>E(R3) = 111001011000000111111110100011110011111010101111

>R(3)XORK(4) = 000001010010011111011000110001110000100101100100

>S(1..8) = 00000111000110110110011111010100

>P = 11000110011101000110000011111001

>R(3)XORL(3) = 10001000100101110110000001101000 =R(4)

>L(4) =R(3) = 11001100001111110001100111010111

>E(R4) = 010001010001010010101110101100000000001101010001

>R(4)XORK(5) = 101001011000001010001000100011101111001101111000

>S(1..8) = 01001100001100001000101000011100

>P = 00011111001010001000000000110100

>R(4)XORL(4) = 11010011000101111001100111100011 =R(5)

>L(5) =R(4) = 10001000100101110110000001101000

>E(R5) = 111010100110100010101111110011110011111100000111

>R(5)XORK(6) = 000010101111101011011101101011010110001001100101

>S(1..8) = 01000010100111101110010001001110

>P = 01001101010101101001000111101000

>R(5)XORL(5) = 11000101110000011111000110000000 =R(6)

>L(6) =R(5) = 11010011000101111001100111100011

>E(R6) = 011000001011111000000011111110100011110000000001

>R(6)XORK(7) = 110001000110110001110001011101101001010100111011

>S(1..8) = 01011110010010011000100110010101

>P = 11010011000010011010100001110011

>R(6)XORL(6) = 00000000000111100011000110010000 =R(7)

>L(7) =R(6) = 11000101110000011111000110000000

>E(R7) = 000000000000000011111100000110100011110010100000

>R(7)XORK(8) = 101001100101001110101110111111110110001011110000

>S(1..8) = 01001010010111110011101010010000

>P = 11110110011010011001000011000001

>R(7)XORL(7) = 00110011101010000110000101000001 =R(8)

>L(8) =R(7) = 00000000000111100011000110010000

>E(R8) = 100110100111110101010000001100000010101000000010

>R(8)XORK(9) = 101111000010111000000011111110111011000001000010

>S(1..8) = 01110001010110001110000010110010

>P = 00000111000001111100011011000011

>R(8)XORL(8) = 00000111000110011111011101010011 =R(9)

>L(9) =R(8) = 00110011101010000110000101000001

>E(R9) = 100000001110100011110011111110101110101010100110

>R(9)XORK(10) = 101011111011100110100010001010100010110110011010

>S(1..8) = 10010101100101101010111010000000

>P = 00010101111000000101000110011011

>R(9)XORL(9) = 00100110010010000011000011011010 =R(10)

>L(10) =R(9) = 00000111000110011111011101010011

>E(R10) = 000100001100001001010000000110100001011011110100

>R(10)XORK(11) = 000111111000001110001001000000110000100001111000

>S(1..8) = 01001001010101100010011101101111

>P = 00001100011110111111110010101000

>R(10)XORL(10) = 00001011011000100000101111111011 =R(11)

>L(11) =R(10) = 00100110010010000011000011011010

>E(R11) = 100001010110101100000100000001010111111111110110

>R(11)XORK(12) = 100110100010101010011101110111010000111101000111

>S(1..8) = 10001110111111101001000000111000

>P = 01101111110010010001010101010100

>R(11)XORL(11) = 01001001100000010010010110001110 =R(12)

>L(12) =R(11) = 00001011011000100000101111111011

>E(R12) = 001001010011110000000010100100001011110001011100

>R(12)XORK(13) = 001110100011010110001011101100111101011001110001

>S(1..8) = 10001000011111110111100000101111

>P = 10111100110011110001110011100100

>R(12)XORL(12) = 10110111101011010001011100011111 =R(13)

>L(13) =R(12) = 01001001100000010010010110001110

>E(R13) = 110110101111110101011010100010101110100011111111

>R(13)XORK(14) = 110000011101010111010111001110001101000101101101

>S(1..8) = 11111011111011000110100110111000

>P = 01011010100011011111011111000111

>R(13)XORL(13) = 00010011000011001101001001001001 =R(14)

>L(14) =R(13) = 10110111101011010001011100011111

>E(R14) = 100010100110100001011001011010100100001001010010

>R(14)XORK(15) = 100100110100010011010101110011110100000101100101

>S(1..8) = 11101100100000101111010010111110

>P = 00101011110011101000011110111001

>R(14)XORL(14) = 10011100011000111001000010100110 =R(15)

>L(15) =R(14) = 00010011000011001101001001001001

>E(R15) = 010011111000001100000111110010100001010100001101

>R(15)XORK(16) = 000111101010111110001011011011010101011011001101

>S(1..8) = 01000100011111111001110111110111

>P = 10110111010100111011110001111101

>R(15)XORL(15) = 10100100010111110110111000110100 =R(16)

>L(16) =R(15) = 10011100011000111001000010100110

9 ()

40 8 48 16 56 24 64 32 39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30 37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28 35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26 33 1 41 9 49 17 57 25

(>L16R16) = 1001110001100011100100001010011010100100010111110110111000110100

= 00110000 00111001 11101011 01101000 01100110 10011011 00111000 11000101 =

48 57 235 104 102 155 56 197 = 0 9 렠 h >f > 8

 

>

>unitUnit1;

>interface

>uses

Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,

Dialogs,StdCtrls;

>type

TForm1 =class(TForm)

Memo1:TMemo;

Memo2:TMemo;

Label1:TLabel;

Label2:TLabel;

Button1:TButton;

Button2:TButton;

Memo3:TMemo;

Label3:TLabel;

procedureButton1Click(Sender:TObject);

procedureButton2Click(Sender:TObject);

private

{Privatedeclarations }

public

{ Publicdeclarations }

end;

>var

Form1:TForm1;

,d,k:array [0..16] ofAnsiString;

r, l,rez,z:AnsiString;

w,desK,desR:byte;

>implementation

{$R *.>dfm}

>procedureDecToBin(input:string;varoutput:ansistring);

>var

a, b:double;

ost,q, w:byte;

st:AnsiString;

str:string[8];

>begin

str:= ' ';

for w:= 1 to 8do

begin

q:=Ord(input[w]);

b:=q;

While b <> 1do

begin

a:=q / 2;

b:=Int(a);

if a = bthen

ost:= 0

elseost:= 1;

q:=Round(b);

st:=st +IntToStr(ost);

if b = 1thenst:=st + '1';

end;

ost:= 1;

forq:=Length(st)downto 1do //

begin

str[ost]:=st[q];

Inc(ost);

end;

caseLength(st) of

1:Insert('0000000',str, 1); //

2:Insert('000000',str, 1);

3:Insert('00000',str, 1);

4:Insert('0000',str, 1);

5:Insert('000',str, 1);

6:Insert('00',str, 1);

7:Insert('0',str, 1);

end;

output:=output +str;// + ' ';

str:= ' ';

st:= '';

end;

end;

>procedureBeginPerestanovka(input:ansistring;varoutput:ansistring);

>begin

output:=

input[58] +input[50] +input[42] +input[34] +input[26] +input[18]

+input[10] +input[2]

+input[60] +input[52] +input[44] +input[36] +input[28] +input[20]

+input[12] +input[4]

+input[62] +input[54] +input[46] +input[38] +input[30] +input[22]

+input[14] +input[6]

+input[64] +input[56] +input[48] +input[40] +input[32] +input[24]

+input[16] +input[8]

+input[57] +input[49] +input[41] +input[33] +input[25] +input[17]

+input[9] +input[1]

+input[59] +input[51] +input[43] +input[35] +input[27] +input[19]

+input[11] +input[3]

+input[61] +input[53] +input[45] +input[37] +input[29] +input[21]

+input[13] +input[5]

+input[63] +input[55] +input[47] +input[39] +input[31] +input[23]

+input[15] +input[7];

end;

>procedurePerestanovkaKeyB(input:AnsiString;varoutput:AnsiString);

>begin

output:= '';

output:=

>input[57]+input[49]+input[41]+input[33]+input[25]+input[17]+input[9]

+>input[1]+input[58]+input[50]+input[42]+input[34]+input[26]+input[18]

+>input[10]+input[2]+input[59]+input[51]+input[43]+input[35]+input[27]

+>input[19]+input[11]+input[3]+input[60]+input[52]+input[44]+input[36]

+>input[63]+input[55]+input[47]+input[39]+input[31]+input[23]+input[15]

+>input[7]+input[62]+input[54]+input[46]+input[38]+input[30]+input[22]

+>input[14]+input[6]+input[61]+input[53]+input[45]+input[37]+input[29]

+>input[21]+input[13]+input[5]+input[28]+input[20]+input[12]+input[4];

end;

>procedurepocledovatelnostiK;

>var

w:byte;

bufer:AnsiString;

>begin

for w:= 0 to 16do

begin

bufer:=Concat(c[w],d[w]);

k[w]:=

Concat(bufer[14],bufer[17],bufer[11],bufer[24],bufer[1],bufer[5],

bufer[3],bufer[28],bufer[15],bufer[6],bufer[21],bufer[10],

bufer[23],bufer[19],bufer[12],bufer[4],bufer[26],bufer[8],

bufer[16],bufer[7],bufer[27],bufer[20],bufer[13],bufer[2],

bufer[41],bufer[52],bufer[31],bufer[37],bufer[47],bufer[55],

bufer[30],bufer[40],bufer[51],bufer[45],bufer[33],bufer[48],

bufer[44],bufer[49],bufer[39],bufer[56],bufer[34],bufer[53],

bufer[46],bufer[42],bufer[50],bufer[36],bufer[29],bufer[32]);

end;

end;

>procedureFuncE;

>const

s1 :array[0..3, 0..15] ofstring[4] =

(('1110','0100','1101','0001','0010','1111','1011','1000','0011','1010','0110','1100','0101','1001','0000','0111'),

('0000','1111','0111','0100','1110','0010','1101','0001','1010','0110','1100','1011','1001','0101','0011','1000'),

('0100','0001','1110','1000','1001','0110','0010','1011','1111','1100','1001','0111','0011','1010','0101','0000'),

('1111','1100','1000','0010','0100','1001','0001','0111','0101','1011','0011','1110','1010','0000','1001','1101'));

s2 :array[0..3, 0..15] ofstring[4] =

(('1111','0001','1000','1110','0110','1011','0011','0100','1001','0111','0010','1101','1100','0000','0101','1010'),

('0011','1101','0100','0111','1111','0010','1000','1110','1100','0000','0001','1010','0110','1001','1011','0101'),

('0000','1110','0111','1011','1010','0100','1101','0001','0101','1000','1100','0110','1001','0011','0010','1111'),

('1101','1000','1010','0001','0011','1111','0100','0010','1011','0110','0111','1100','0000','0101','1110','1001'));

s3 :array [0..3, 0..15] ofstring[4] =

(('1010','0000','1001','1110','0110','0011','1111','0101','0001','1101','1100','0111','1011','0100','0010','1000'),

('1101','0111','0000','1001','0011','0100','0110','1010','0010','1000','0101','1110','1100','1011','1111','0001'),

('1101','0110','0100','1001','1000','1111','0011','0000','1011','0001','0010','1100','0101','1010','1110','0111'),

('0001','1010','1101','0000','0110','1001','1000','0111','0100','1111','1110','0011','1011','0101','0010','1100'));

s4 :array [0..3, 0..15] ofstring[4] =

(('0111','1101','1110','0011','0000','0110','1001','1010','0001','0010','1000','0101','1011','1100','0100','1111'),

('1101','1000','1011','0101','0110','1111','0000','0011','0100','0111','0010','1100','0001','1010','1110','1001'),

('1010','0110','1001','0000','1100','1011','0111','1101','1111','0001','0011','1110','0101','0010','1000','0100'),

('0011','1111','0000','0110','1010','0001','1101','1000','1001','0100','0101','1011','1100','0111','0010','1110'));

s5 :array [0..3, 0..15] ofstring[4] =

(('0010','1100','0100','0001','0111','1010','1011','0110','1000','0101','0011','1111','1101','0000','1110','1001'),

('1110','1011','0010','1100','0100','0111','1101','0001','0101','0000','1111','1010','0011','1001','1000','0110'),

('0100','0010','0001','1011','1010','1101','0111','1000','1111','1001','1100','0101','0110','0011','0000','1110'),

('1011','1000','1100','0111','0001','1110','0010','1101','0110','1111','0000','1001','1010','0100','0101','0011'));

s6 :array [0..3, 0..15] ofstring[4] =

(('1100','0001','1010','1111','1001','0010','0110','1000','0000','1101','0011','0100','1110','0111','0101','1011'),

('1010','1111','0100','0010','0111','1100','1001','0101','0110','0001','1101','1110','0000','1011','0011','1000'),

('1001','1110','1111','0101','0010','1000','1100','0011','0111','0000','0100','1010','0001','1101','1011','0110'),

('0100','0011','0010','1100','1001','0101','1111','1010','1011','1110','0001','0111','0110','0000','1000','1101'));

s7 :array [0..3, 0..15] ofstring[4] =

(('0100','1011','0010','1110','1111','0000','1000','1101','0011','1100','1001','0111','0101','1010','0110','0001'),

('1101','0000','1011','0111','0100','1001','0001','1010','1110','0011','0101','1100','0011','1111','1000','0110'),

('0001','0100','1011','1101','1100','0011','0111','1110','1010','1111','0110','1000','0000','0101','1001','0010'),

('0110','1011','1101','1000','0001','0100','1010','0111','1001','0101','0000','1111','1110','0010','0011','1100'));

s8 :array [0..3, 0..15] ofstring[4] =

(('1101','0010','1000','0100','0110','1111','1011','0001','1010','1001','0011','1110','0101','0000','1100','0111'),

('0001','1111','1101','1000','1010','0011','0111','0100','1100','0101','0110','1011','0000','1110','1001','0011'),

('0111','1011','0100','0001','1001','1100','1110','0010','0000','0110','1010','1101','1111','0011','0101','1000'),

('0010','0001','1110','0111','0100','1010','1000','1101','1111','1100','1001','0000','0011','0101','0110','1011'));

>var

_1, _2:AnsiString;

p:string[6];

v, b, x, a, j:byte;

u:string[2];

o:string[4];

>functions(var a, b:byte):byte;

>begin

if u = '00'then a:= 0

elseif u = '01'then a:= 1

elseif u = '10'then a:= 2

elseif u = '11'then a:= 3;

ifo = '0000'then b:= 0

elseifo = '0001'then b:= 1

elseifo = '0010'then b:= 2

elseifo = '0011'then b:= 3

elseifo = '0100'then b:= 4

elseifo = '0101'then b:= 5

elseifo = '0110'then b:= 6

elseifo = '0111'then b:= 7

elseifo = '1000'then b:= 8

elseifo = '1001'then b:= 9

elseifo = '1010'then b:= 10

elseifo = '1011'then b:= 11

elseifo = '1100'then b:= 12

elseifo = '1101'then b:= 13

elseifo = '1110'then b:= 14

elseifo = '1111'then b:= 15;

end;

>begin

>for a:= 1 to 16do

begin

z:=Concat(r[32],r[1],r[2],r[3],r[4],r[5],r[4],r[5],r[6],r[7],r[8],r[9],

r[8],r[9],r[10],r[11],r[12],r[13],r[12],r[13],r[14],r[15],r[16],r[17],

>r[16],r[17],r[18],r[19],r[20],r[21],r[20],r[21],r[21],r[23],r[24],r[25],

>r[24],r[25],r[26],r[27],r[28],r[29],r[28],r[29],r[30],r[31],r[32],r[1]);

_1:=k[a];

r:=z;

for j:= 1 to 48do //xor

begin

v:=StrToInt(r[j]);

b:=StrToInt(_1[j]);

x:= vxor b;

_2:=Concat(_2,IntToStr(x));

end;

p:=Copy(_2, 1, 6); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s1[v, b];

p:=Copy(_2, 7, 12); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s2[v, b];

p:=Copy(_2, 13, 18); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s3[v, b];

p:=Copy(_2, 19, 24); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s4[v, b];

p:=Copy(_2, 25, 30); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s5[v, b];

p:=Copy(_2, 31, 36); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s6[v, b];

p:=Copy(_2, 37, 42); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s7[v, b];

p:=Copy(_2, 43, 48); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s8[v, b];

//

_2:=rez;

rez:=Concat(_2[16], _2[7], _2[20], _2[21], _2[29], _2[12], _2[28], _2[17],

_2[1], _2[15], _2[23], _2[26], _2[5], _2[18], _2[31], _2[10],

_2[2], _2[8], _2[24], _2[14], _2[32], _2[27], _2[3], _2[9],

_2[19], _2[13], _2[30], _2[6], _2[22], _2[11], _2[4], _2[25]);

for w:= 1 to 32do

begin

v:=StrToInt(r[w]);

b:=StrToInt(l[w]);

x:= vxor b;

_2:=Concat(_2,IntToStr(x));

end;

l:=r;

r:= _2;

end;

_2:=Concat(l,r);

>rez:=Concat(

_2[40], _2[8], _2[48], _2[16], _2[56], _2[24], _2[64], _2[32],

_2[39], _2[7], _2[47], _2[15], _2[55], _2[23], _2[63], _2[31],

_2[38], _2[6], _2[46], _2[14], _2[54], _2[22], _2[62], _2[30],

_2[37], _2[5], _2[45], _2[13], _2[53], _2[21], _2[61], _2[29],

_2[36], _2[4], _2[44], _2[12], _2[52], _2[20], _2[60], _2[28],

_2[35], _2[3], _2[43], _2[11], _2[51], _2[19], _2[59], _2[27],

_2[34], _2[2], _2[42], _2[10], _2[50], _2[18], _2[58], _2[26],

_2[33], _2[1], _2[41], _2[9], _2[49], _2[17], _2[57], _2[25]);

end;

>procedureFuncER;

>const

s1 :array[0..3, 0..15] ofstring[4] =

(('1110','0100','1101','0001','0010','1111','1011','1000','0011','1010','0110','1100','0101','1001','0000','0111'),

('0000','1111','0111','0100','1110','0010','1101','0001','1010','0110','1100','1011','1001','0101','0011','1000'),

('0100','0001','1110','1000','1001','0110','0010','1011','1111','1100','1001','0111','0011','1010','0101','0000'),

('1111','1100','1000','0010','0100','1001','0001','0111','0101','1011','0011','1110','1010','0000','1001','1101'));

s2 :array[0..3, 0..15] ofstring[4] =

(('1111','0001','1000','1110','0110','1011','0011','0100','1001','0111','0010','1101','1100','0000','0101','1010'),

('0011','1101','0100','0111','1111','0010','1000','1110','1100','0000','0001','1010','0110','1001','1011','0101'),

('0000','1110','0111','1011','1010','0100','1101','0001','0101','1000','1100','0110','1001','0011','0010','1111'),

('1101','1000','1010','0001','0011','1111','0100','0010','1011','0110','0111','1100','0000','0101','1110','1001'));

s3 :array [0..3, 0..15] ofstring[4] =

(('1010','0000','1001','1110','0110','0011','1111','0101','0001','1101','1100','0111','1011','0100','0010','1000'),

('1101','0111','0000','1001','0011','0100','0110','1010','0010','1000','0101','1110','1100','1011','1111','0001'),

('1101','0110','0100','1001','1000','1111','0011','0000','1011','0001','0010','1100','0101','1010','1110','0111'),

('0001','1010','1101','0000','0110','1001','1000','0111','0100','1111','1110','0011','1011','0101','0010','1100'));

s4 :array [0..3, 0..15] ofstring[4] =

(('0111','1101','1110','0011','0000','0110','1001','1010','0001','0010','1000','0101','1011','1100','0100','1111'),

('1101','1000','1011','0101','0110','1111','0000','0011','0100','0111','0010','1100','0001','1010','1110','1001'),

('1010','0110','1001','0000','1100','1011','0111','1101','1111','0001','0011','1110','0101','0010','1000','0100'),

('0011','1111','0000','0110','1010','0001','1101','1000','1001','0100','0101','1011','1100','0111','0010','1110'));

s5 :array [0..3, 0..15] ofstring[4] =

(('0010','1100','0100','0001','0111','1010','1011','0110','1000','0101','0011','1111','1101','0000','1110','1001'),

('1110','1011','0010','1100','0100','0111','1101','0001','0101','0000','1111','1010','0011','1001','1000','0110'),

('0100','0010','0001','1011','1010','1101','0111','1000','1111','1001','1100','0101','0110','0011','0000','1110'),

('1011','1000','1100','0111','0001','1110','0010','1101','0110','1111','0000','1001','1010','0100','0101','0011'));

s6 :array [0..3, 0..15] ofstring[4] =

(('1100','0001','1010','1111','1001','0010','0110','1000','0000','1101','0011','0100','1110','0111','0101','1011'),

('1010','1111','0100','0010','0111','1100','1001','0101','0110','0001','1101','1110','0000','1011','0011','1000'),

('1001','1110','1111','0101','0010','1000','1100','0011','0111','0000','0100','1010','0001','1101','1011','0110'),

('0100','0011','0010','1100','1001','0101','1111','1010','1011','1110','0001','0111','0110','0000','1000','1101'));

s7 :array [0..3, 0..15] ofstring[4] =

(('0100','1011','0010','1110','1111','0000','1000','1101','0011','1100','1001','0111','0101','1010','0110','0001'),

('1101','0000','1011','0111','0100','1001','0001','1010','1110','0011','0101','1100','0011','1111','1000','0110'),

('0001','0100','1011','1101','1100','0011','0111','1110','1010','1111','0110','1000','0000','0101','1001','0010'),

('0110','1011','1101','1000','0001','0100','1010','0111','1001','0101','0000','1111','1110','0010','0011','1100'));

s8 :array [0..3, 0..15] ofstring[4] =

(('1101','0010','1000','0100','0110','1111','1011','0001','1010','1001','0011','1110','0101','0000','1100','0111'),

('0001','1111','1101','1000','1010','0011','0111','0100','1100','0101','0110','1011','0000','1110','1001','0011'),

('0111','1011','0100','0001','1001','1100','1110','0010','0000','0110','1010','1101','1111','0011','0101','1000'),

('0010','0001','1110','0111','0100','1010','1000','1101','1111','1100','1001','0000','0011','0101','0110','1011'));

>var

_1, _2:AnsiString;

p:string[6];

v, b, x, a, j:byte;

u:string[2];

o:string[4];

>functions(var a, b:byte):byte;

>begin

if u = '00'then a:= 0

elseif u = '01'then a:= 1

elseif u = '10'then a:= 2

elseif u = '11'then a:= 3;

ifo = '0000'then b:= 0

elseifo = '0001'then b:= 1

elseifo = '0010'then b:= 2

elseifo = '0011'then b:= 3

elseifo = '0100'then b:= 4

elseifo = '0101'then b:= 5

elseifo = '0110'then b:= 6

elseifo = '0111'then b:= 7

elseifo = '1000'then b:= 8

elseifo = '1001'then b:= 9

elseifo = '1010'then b:= 10

elseifo = '1011'then b:= 11

elseifo = '1100'then b:= 12

elseifo = '1101'then b:= 13

elseifo = '1110'then b:= 14

elseifo = '1111'then b:= 15;

end;

>begin

>for a:= 16downto 1do

begin

z:=Concat(r[32],r[1],r[2],r[3],r[4],r[5],r[4],r[5],r[6],r[7],r[8],r[9],

r[8],r[9],r[10],r[11],r[12],r[13],r[12],r[13],r[14],r[15],r[16],r[17],

>r[16],r[17],r[18],r[19],r[20],r[21],r[20],r[21],r[21],r[23],r[24],r[25],

>r[24],r[25],r[26],r[27],r[28],r[29],r[28],r[29],r[30],r[31],r[32],r[1]);

_1:=k[a];

r:=z;

for j:= 1 to 48do //xor

begin

v:=StrToInt(r[j]);

b:=StrToInt(_1[j]);

x:= vxor b;

_2:=Concat(_2,IntToStr(x));

end;

p:=Copy(_2, 1, 6); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s1[v, b];

p:=Copy(_2, 7, 12); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s2[v, b];

p:=Copy(_2, 13, 18); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s3[v, b];

p:=Copy(_2, 19, 24); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s4[v, b];

p:=Copy(_2, 25, 30); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s5[v, b];

p:=Copy(_2, 31, 36); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s6[v, b];

p:=Copy(_2, 37, 42); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s7[v, b];

p:=Copy(_2, 43, 48); u:=p[1] +p[6];o:=Copy(p, 2, 5);s(v, b);

rez:=rez +s8[v, b];

//

_2:=rez;

rez:=Concat(_2[16], _2[7], _2[20], _2[21], _2[29], _2[12], _2[28], _2[17],

_2[1], _2[15], _2[23], _2[26], _2[5], _2[18], _2[31], _2[10],

_2[2], _2[8], _2[24], _2[14], _2[32], _2[27], _2[3], _2[9],

_2[19], _2[13], _2[30], _2[6], _2[22], _2[11], _2[4], _2[25]);

for w:= 1 to 32do

begin

v:=StrToInt(r[w]);

b:=StrToInt(l[w]);

x:= vxor b;

_2:=Concat(_2,IntToStr(x));

end;

l:=r;

r:= _2;

end;

_2:=Concat(l,r);

rez:=Concat(

_2[40], _2[8], _2[48], _2[16], _2[56], _2[24], _2[64], _2[32],

_2[39], _2[7], _2[47], _2[15], _2[55], _2[23], _2[63], _2[31],

_2[38], _2[6], _2[46], _2[14], _2[54], _2[22], _2[62], _2[30],

_2[37], _2[5], _2[45], _2[13], _2[53], _2[21], _2[61], _2[29],

_2[36], _2[4], _2[44], _2[12], _2[52], _2[20], _2[60], _2[28],

_2[35], _2[3], _2[43], _2[11], _2[51], _2[19], _2[59], _2[27],

_2[34], _2[2], _2[42], _2[10], _2[50], _2[18], _2[58], _2[26],

_2[33], _2[1], _2[41], _2[9], _2[49], _2[17], _2[57], _2[25]);

end;

>procedureTForm1.Button1Click(Sender:TObject);

>var

>output,put,key,c0,d0,k0:AnsiString;

>e1:string[1];

>e2:string[2];

>begin

DecToBin(Form1.Memo1.Text,output);

BeginPerestanovka(output,put);

l:=Copy(put, 1, 32);

r:=Copy(put, 33, 64);

DecToBin(Form1.Memo3.Text,key);

PerestanovkaKeyB(key,key);

c0:=Copy(key, 1, 28);

d0:=Copy(key, 29, 56);

c[0]:=c0;

d[0]:=d0;

for w:= 1 to 2do

begin

e1:=c[w-1];

c[w]:=Copy(c[w-1], 2, 28) +e1;

e1:=d[w-1];

d[w]:=Copy(d[w-1], 2, 28) +e1;

end;

for w:= 3 to 8do

begin

e2:=c[w-1];

c[w]:=Copy(c[w-1], 3, 28) +e2;

e2:=d[w-1];

d[w]:=Copy(d[w-1], 3, 28) +e2;

end;

e1:=c[8];

c[9]:=Copy(c[8], 2, 28) +e1;

e1:=d[8];

d[w]:=Copy(d[8], 2, 28) +e1;

for w:= 10 to 15do

begin

e2:=c[w-1];

c[w]:=Copy(c[w-1], 3, 28) +e2;

e2:=d[w-1];

d[w]:=Copy(d[w-1], 3, 28) +e2;

end;

e1:=c[15];

c[16]:=Copy(c[15], 2, 28) +e1;

e1:=d[15];

d[16]:=Copy(d[15], 2, 28) +e1;

pocledovatelnostiK;

FuncE;

Form1.Memo2.Text:=rez;

end;

>procedureTForm1.Button2Click(Sender:TObject);

>var

>output,put,key,c0,d0,k0:AnsiString;

>e1:string[1];

>e2:string[2];

>begin

>DecToBin(Form1.Memo2.Text,output);

BeginPerestanovka(output,put);

l:=Copy(put, 1, 32);

r:=Copy(put, 33, 64);

DecToBin(Form1.Memo3.Text,key);

PerestanovkaKeyB(key,key);

c0:=Copy(key, 1, 28);

d0:=Copy(key, 29, 56);

c[0]:=c0;

d[0]:=d0;

for w:= 1 to 2do

begin

e1:=c[w-1];

c[w]:=Copy(c[w-1], 2, 28) +e1;

e1:=d[w-1];

d[w]:=Copy(d[w-1], 2, 28) +e1;

end;

for w:= 3 to 8do

begin

e2:=c[w-1];

c[w]:=Copy(c[w-1], 3, 28) +e2;

e2:=d[w-1];

d[w]:=Copy(d[w-1], 3, 28) +e2;

end;

e1:=c[8];

c[9]:=Copy(c[8], 2, 28) +e1;

e1:=d[8];

d[w]:=Copy(d[8], 2, 28) +e1;

for w:= 10 to 15do

begin

e2:=c[w-1];

c[w]:=Copy(c[w-1], 3, 28) +e2;

e2:=d[w-1];

d[w]:=Copy(d[w-1], 3, 28) +e2;

end;

e1:=c[15];

c[16]:=Copy(c[15], 2, 28) +e1;

e1:=d[15];

d[16]:=Copy(d[15], 2, 28) +e1;

pocledovatelnostiK;

FuncER;

Form1.Memo1.Text:=rez;

end;

end.


| 3 3

:

    1. -
    2. ³
    3. ,
    4. '
    5. , '
    6. ̳
    7. ,
    8. ,
    9. ,
    10. Գ
    11. Գ
    12. Գ
    13. Գ
    14. ճ
    15. -
    16. ,