Category : Utilities for DOS and Windows Machines
Archive   : CODEIT.ZIP
Filename : DECODEIT.PAS

 
Output of file : DECODEIT.PAS contained in archive : CODEIT.ZIP
Program DECODEIT;
Const
MaxBuf = 30000;
Var
Password : String[6];
seed1, seed2, seed1x, seed2x : Byte;
source, dest : File;
buffer : Array [1..MaxBuf] of Byte;
BytesRead : Real;
i : Integer;

(********************************************************************)

Procedure OpenFiles;
Const
s : Array [1..6] Of Char = ('L','O','C','K','E','D');
Begin
Assign(source,ParamStr(1));
(*$I-*)
Reset(source,1);
(*$I+*)
If IOResult <> 0 Then
Begin
Writeln('File not found.');
Halt;
End;

BlockRead(source,buffer,6);
If Not ((buffer[1] = ord('L')) And
(buffer[2] = ord('O')) And
(buffer[3] = ord('C')) And
(buffer[4] = ord('K')) And
(buffer[5] = ord('E')) And
(buffer[6] = ord('D'))) Then
Begin
Writeln('File is not locked.');
Halt;
End;

BlockRead(source,Seed1x, 1);
BlockRead(source,Seed2x, 1);

If ((seed1 <> Seed1x) OR (seed2 <> Seed2x)) Then
Begin
Writeln('Wrong Password.');
Halt;
End;

Assign(dest,'$$$$$.$$');
Rewrite(dest,1);

End;

(****************************************************************)

Procedure GetSeed;
Var
i, j : Integer;
Begin
Seed1 := 0;
Seed2 := 0;
Password := ParamStr(2);

j := Length(Password);
For i:= 1 to Length(Password) Do
Begin
Seed1 := Seed1 + (Ord(Password[i]) * i);
Seed2 := Seed2 + (Ord(Password[i]) * i);
j := j - 1;
End;
End;

(*****************************************************************)

Procedure DecodeFiles;
Var
i1, i2 : Byte;
rr : Integer;
Begin
i1 := Seed1;
i2 := Seed2;
BytesRead := 0;
BlockRead(source, buffer, MaxBuf, rr);
BytesRead := BytesRead + rr;
While rr > 0 Do
Begin
For i := 1 to rr Do
Begin
i1 := i1 - i;
i2 := i2 +i;
If odd(i) Then
buffer[i] := buffer[i] + i1
Else
buffer[i] := buffer[i] - i2;
End;
BlockWrite(dest, buffer, rr);
BlockRead(source, buffer, MaxBuf, rr);
BytesRead := BytesRead + rr;
End;
End;

(*******************************************************************)

Procedure CloseFiles;
Var
i : Integer;
Begin
Rewrite(source, 1);
FillChar(buffer, MaxBuf, 0);
While BytesRead > 0 Do
Begin
If BytesRead > MaxBuf Then
BlockWrite(source, buffer, MaxBuf)
Else
Begin
i := Trunc(BytesRead);
BlockWrite(source, buffer, i);
End;
BytesRead := BytesRead - MaxBuf;
End;
Close(source);
Close(dest);
Erase(source);
Rename(dest, ParamStr(1));
End;

(***************************************************************)


Begin
If Paramcount <> 2 Then
Begin
Writeln('Syntax: DECODEIT Filename password');
Halt;
End;
Getseed;
OpenFiles;
DecodeFiles;
CloseFiles;
End.

  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : CODEIT.ZIP
Filename : DECODEIT.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/