Home > Back-end >  O algorithm
O algorithm

Time:10-12

Const
DEFAULT_M: array [0.. lF] of byte=
(l1, l6, lF, l8, l8, lC, l0, lD, l2, l3, l01, LDF, LSS, LDD, ld1, ld8);
Procedure inBuf (var Buf: an array of Byte);
Var
I: Integer;
D, c: byte;
Index: Integer;
The begin
D:=0;
C:=0;
For I:=low (Buf) to High (Buf) do
The begin
Index:=I mod 16;
D:=DEFAULT_M [Index];
D:=d + c;
C:=byte (Buf [I]);
C:=c xor d;
Buf: [I]=c;
end;
end;
Because not the language, so watch this algorithm for a long time did not understand, please look at the,
How to decrypt the encrypted, want

CodePudding user response:

Is simply a modulus, an exclusive or, can have what not understand


Const//this constant array declaration defines all wrong, is 1 f displays hexadecimal, it should be $1 f
DEFAULT_M: array [0.. lF] of byte=
(l1, l6, lF, l8, l8, lC, l0, lD, l2, l3, l01, LDF, LSS, LDD, ld1, ld8);//these values obviously write, for example use of


The begin
D:=0;
C:=0;
For I:=low (Buf) to High (Buf) do//cycle the entire Buf
The begin
Index:=I mod 16; 16//index=I %
D:=DEFAULT_M [Index];
D:=d + c;
C:=byte (Buf [I]);
C:=c xor d;//c=c ^ d;
Buf: [I]=c;
end;

CodePudding user response:

The above array DEFAULT_M is encrypted,
Arrays Buf is processed,
Processing for the results of c and this is used to encrypt bytes up to get the coefficient is used to encrypt, the new coefficient modulus on the need to encrypt bytes received the processing result,

CodePudding user response:

Decryption, in turn,
With the last results and this is used to encrypt a byte plus get coefficient for xor, and the results are different or is then released,
Procedure inBuf (var Buf: an array of Byte);
Var
I: Integer;
D, c: byte;
Index: Integer;
The begin
D:=0;
C:=0;
For I:=low (Buf) to High (Buf) do
The begin
Index:=I mod 16;
D:=DEFAULT_M [Index];
D:=d + c;
C:=byte (Buf [I]);
Buf [I] :=c xor d;
end;
end;
Only a few changes and encryption,

CodePudding user response:

Thank you teach!!!!!!!!!
  • Related