1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
procedure crypt(var st:tmemorystream);
var pass:string;
i,j,l,currentpos,nb,pos:longint;
c,r:byte;
buf:array[0..8191] of byte;
key:array[0..255] of byte;
begin
pass:='Le pass de 64 octets finalement j'en prend 64 et non plus 256';
l:=length(pass);
for i:=1 to l do
begin
key[i-1]:=ord(pass[i]);
end;
st.Position:=0;
// partie à traduire en assembleur
currentpos:=0;
j:=0;
while (currentpos<st.size-1)
do
begin
pos := st.Position;
nb := st.Read(buf,8191);
currentpos:=currentpos+nb;
for i:= 0 to nb do
begin
buf[i]:=buf[i] xor (key[j]);
inc(j);
if j>=l then j:=0;
end;
st.position:=pos;
st.Write(buf,nb);
end; // while
// fin de la mise en assembleur
st.position:=0;
end; |
Partager