home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug097.arc / NAME.PAS < prev    next >
Pascal/Delphi Source File  |  1979-12-31  |  3KB  |  112 lines

  1. program encrypt_system;
  2.  
  3. { This program names and encrypts an operating system    }
  4. {   prior to storage on disk.                            }
  5. { THIS PROGRAM IS NOT TO BE RELEASED TO ANYONE !!!!      }
  6. {              THIS MEANS YOU !!!!                       }
  7. { Matches system version 2.2, 17/5/88 and after.         }
  8. { Actually this does not do any encryption as that       }
  9. {   section of the operating system no longer works!     }
  10.  
  11. var
  12.     in_file, out_file : file;
  13.     buffer : array [0..$27FF] of byte;
  14.     in_file_name, out_file_name : string [14];
  15.     name : string [30];
  16.     i, ch_byte, start_check, end_check, name_pos, encrypt_start, encrypt_end,
  17.       rot_val : integer;
  18.     check_sum, encr_byte : byte;
  19.     key : char;
  20.  
  21. label
  22.     end_loop;
  23.  
  24. begin
  25.     if paramcount<>2 then
  26.       begin
  27.         write(^J'Enter source file name - ');
  28.         readln(in_file_name);
  29.         write(^J'Enter destination file name - ');
  30.         readln(out_file_name);
  31.       end
  32.     else
  33.       begin
  34.         in_file_name:=paramstr(1);
  35.         out_file_name:=paramstr(2);
  36.       end;
  37.     assign(in_file,in_file_name);
  38.     reset(in_file);
  39.     blockread(in_file,buffer,80);
  40.     close(in_file);
  41.     repeat
  42.       write(^J'Enter name - ');
  43.       readln(name);
  44.       writeln(^J'This disk belongs to ',name,'.'^J);
  45.       write('Is this correct ? ');
  46.       repeat
  47.         read(kbd,key);
  48.         key:=upcase(key);
  49.        until (key='Y') or (key='N');
  50.       writeln(key,^J);
  51.     until key='Y';
  52.     for i:=succ(length(name)) to 30 do
  53.       name[i]:=#0;
  54.     for i:=$1000 to $27FF do
  55.       begin
  56. (*
  57.        { start of boot code to check }
  58.        if (buffer[i]=$FF) then
  59.           if (buffer[succ(i)]=$11) then
  60.             if (buffer[i+2]=$22) then
  61.               start_check:=i;
  62.         { end of boot code to check }
  63.         if (buffer[i]=$FF) then
  64.           if (buffer[succ(i)]=$33) then
  65.             if (buffer[i+2]=$44) then
  66.               end_check:=i;
  67. *)
  68.         { start of space for user name }
  69.         if (char(buffer[i])='!') then
  70.           if (char(buffer[succ(i)])='@') then
  71.             if (char(buffer[i+2])='#') then
  72.               begin
  73.                 name_pos:=i;
  74.                 goto end_loop;
  75.               end;
  76. (*
  77.         { start of area to encrypt }
  78.         if (buffer[i]=$98) then
  79.           if (buffer[succ(i)]=$76) then
  80.             if (buffer[i+2]=$54) then
  81.               encrypt_start:=i;
  82.         if (buffer[i]=$12) then
  83.           if (buffer[succ(i)]=$34) then
  84.             if (buffer[i+2]=$56) then
  85.               encrypt_end:=i;
  86. *)
  87.       end;
  88. end_loop:
  89.       for i:=1 to 30 do
  90.         buffer[pred(name_pos+i)]:=byte(name[i]);
  91. (*
  92.       check_sum:=0;
  93.       for i:=start_check+4 to end_check-1 do
  94.         begin
  95.           rot_val:=(buffer[i] + i) and 7;
  96.           ch_byte:=buffer[succ(i)];
  97.           ch_byte:=lo((ch_byte+(ch_byte shl 8)) shr rot_val);
  98.           check_sum:=lo(check_sum+ch_byte);
  99.         end;
  100.       encr_byte:=0;
  101.       for i:=encrypt_start to encrypt_end+3 do
  102.         begin
  103.           encr_byte:=lo(encr_byte+check_sum);
  104.           buffer[i]:=buffer[i] xor encr_byte xor lo(i);
  105.         end;
  106. *)
  107.       assign(out_file,out_file_name);
  108.       rewrite(out_file);
  109.       blockwrite(out_file,buffer,80);
  110.       close(out_file);
  111. end.
  112.