Skip to content

Latest commit

 

History

History
68 lines (59 loc) · 1.5 KB

mdek.pas

File metadata and controls

68 lines (59 loc) · 1.5 KB
 
Nov 18, 2000
Nov 18, 2000
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit mdek;
interface
{rcg11172000 no overlay under Linux.}
{uses overlay;}
function encrypt(os:string; c1,c2,c3,c4,c5,c6:byte):string;
function decrypt(os:string; c1,c2,c3,c4,c5,c6:byte):string;
implementation
function encrypt(os:string; c1,c2,c3,c4,c5,c6:byte):string;
var ns:string;
codes:array[1..6] of byte;
c,d,i,j,k,l:integer;
begin
for i:=1 to 6 do
case i of 1:codes[i]:=c1; 2:codes[i]:=c2; 3:codes[i]:=c3;
4:codes[i]:=c4; 5:codes[i]:=c5; 6:codes[i]:=c6; end;
j:=0; k:=1; l:=1;
for i:=1 to length(os) do begin
inc(j);
if (j>6) then begin
dec(k); j:=1;
if (k<1) then begin
dec(l); k:=6;
if (l<1) then begin
j:=1; k:=6; l:=6;
end;
end;
end;
d:=codes[j]+codes[k]+codes[l];
os[i]:=chr((ord(os[i])+d) mod 256);
end;
encrypt:=os;
end;
function decrypt(os:string; c1,c2,c3,c4,c5,c6:byte):string;
var ns:string;
codes:array[1..6] of byte;
c,d,i,j,k,l:integer;
begin
for i:=1 to 6 do
case i of 1:codes[i]:=c1; 2:codes[i]:=c2; 3:codes[i]:=c3;
4:codes[i]:=c4; 5:codes[i]:=c5; 6:codes[i]:=c6; end;
j:=0; k:=1; l:=1;
for i:=1 to length(os) do begin
inc(j);
if (j>6) then begin
dec(k); j:=1;
if (k<1) then begin
dec(l); k:=6;
if (l<1) then begin
j:=1; k:=6; l:=6;
end;
end;
end;
d:=codes[j]+codes[k]+codes[l];
os[i]:=chr((1024+(ord(os[i])-d)) mod 256);
end;
decrypt:=os;
end;
end.