Advertisement
uno20001

SimpleCrypt (GYK) (PAS)

Sep 10th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 5.17 KB | None | 0 0
  1. program gyk2;
  2.  
  3. uses crt,dos;
  4. const n=2;
  5.  
  6. var
  7.     m :array[0..n, 0..255] of byte = (
  8.         (
  9.             54, 107, 184, 49, 244, 234, 44, 7, 2, 165, 144, 45, 189, 196, 172, 95, 178, 38, 168, 85, 88, 187, 227, 241, 152, 82, 190, 51, 211, 92, 96, 162, 131, 35, 175, 176, 158, 13, 34, 188, 81, 123, 111, 98, 180, 36, 108, 117, 71, 151, 64, 223, 16, 29, 46, 225, 37, 248, 226, 185, 135, 15, 129, 183, 246, 39, 41, 200, 134, 130, 101, 72, 73, 149, 193, 127, 28, 153, 6, 146, 133, 78, 204, 50,
  10.             126, 23, 181, 67, 86, 219, 232, 18, 17, 8, 238, 177, 14, 250, 57, 104, 76, 186, 150, 121, 171, 10, 79, 120, 31, 137, 191, 195, 239, 25, 74, 80, 182, 68, 58, 12, 103, 228, 52, 70, 206, 166, 199, 4, 201, 197, 230, 60, 119, 140, 22, 216, 205, 222, 243, 110, 139, 208, 59, 33, 170, 154, 229, 105, 247, 106, 20, 242, 136, 164, 27, 251, 62, 253, 24, 159, 5, 56, 48, 89, 210, 255, 109, 231, 233, 218,
  11.             112, 212, 213, 167, 143, 9, 1, 203, 254, 97, 113, 47, 160, 125, 21, 55, 26, 32, 114, 145, 53, 11, 240, 83, 142, 221, 124, 215, 252, 3, 91, 118, 217, 100, 99, 61, 236, 161, 224, 202, 43, 30, 237, 169, 77, 42, 249, 209, 122, 155, 157, 138, 94, 179, 0, 198, 63, 93, 115, 174, 220, 245, 194, 207, 84, 40, 163, 235, 69, 66, 132, 148, 214, 19, 116, 192, 87, 156, 141, 75, 128, 90, 102, 173, 147, 65
  12.         ),
  13.         (
  14.             54, 107, 184, 49, 244, 234, 44, 7, 2, 165, 144, 45, 189, 196, 172, 95, 178, 38, 168, 85, 88, 187, 227, 241, 152, 82, 190, 51, 211, 92, 96, 162, 131, 35, 175, 176, 158, 13, 34, 188, 81, 123, 111, 98, 180, 36, 108, 117, 71, 151, 64, 223, 16, 29, 46, 225, 37, 248, 226, 185, 135, 15, 129, 183, 246, 39, 41, 200, 134, 130, 101, 72, 73, 149, 193, 127, 28, 153, 6, 146, 133, 78, 204, 50, 126, 23,
  15.             181, 67, 86, 219, 232, 18, 17, 8, 238, 177, 14, 250, 57, 104, 76, 186, 150, 121, 171, 10, 79, 120, 31, 137, 191, 195, 239, 25, 74, 80, 182, 68, 58, 12, 103, 228, 52, 70, 206, 166, 199, 4, 201, 197, 230, 60, 119, 140, 22, 216, 205, 222, 243, 110, 139, 208, 59, 33, 170, 154, 229, 105, 247, 106, 20, 242, 136, 164, 27, 251, 62, 253, 24, 159, 5, 56, 48, 89, 210, 255, 109, 231, 233, 218, 112, 212,
  16.             213, 167, 143, 9, 1, 203, 254, 97, 113, 47, 160, 125, 21, 55, 26, 32, 114, 145, 53, 11, 240, 83, 142, 221, 124, 215, 252, 3, 91, 118, 217, 100, 99, 61, 236, 161, 224, 202, 43, 30, 237, 169, 77, 42, 249, 209, 122, 155, 157, 138, 94, 179, 0, 198, 63, 93, 115, 174, 220, 245, 194, 207, 84, 40, 163, 235, 69, 66, 132, 148, 214, 19, 116, 192, 87, 156, 141, 75, 128, 90, 102, 173, 147, 65
  17.         ),
  18.         (
  19.             88, 36, 114, 146, 226, 236, 96, 177, 213, 248, 153, 8, 22, 180, 192, 205, 238, 90, 63, 242, 55, 118, 130, 34, 124, 82, 111, 89, 121, 119, 165, 190, 170, 135, 76, 35, 78, 24, 79, 83, 216, 166, 18, 206, 68, 223, 108, 16, 86, 19, 81, 48, 207, 127, 110, 151, 23, 234, 173, 148, 197, 131, 202, 138, 25, 49, 241, 193, 71, 159, 167, 26, 61, 164, 249, 97, 245, 149, 66, 253, 225, 144, 12, 188, 158, 161, 123, 0,
  20.             179, 230, 162, 128, 134, 38, 1, 3, 160, 10, 6, 254, 231, 5, 172, 240, 100, 171, 211, 133, 9, 169, 42, 105, 195, 125, 31, 227, 122, 176, 181, 168, 120, 141, 13, 175, 106, 17, 228, 113, 2, 65, 92, 214, 194, 189, 109, 126, 157, 101, 32, 215, 99, 54, 43, 104, 40, 145, 14, 250, 232, 221, 139, 203, 20, 137, 140, 229, 45, 57, 150, 94, 117, 93, 75, 95, 218, 67, 243, 84, 116, 255, 27, 209, 183, 51,
  21.             182, 208, 184, 246, 39, 56, 29, 156, 219, 152, 201, 155, 70, 85, 199, 30, 132, 77, 107, 154, 74, 4, 91, 52, 185, 247, 87, 244, 174, 136, 80, 239, 47, 220, 46, 196, 59, 72, 21, 28, 112, 15, 60, 233, 143, 50, 41, 58, 73, 129, 204, 210, 37, 11, 44, 251, 7, 212, 217, 235, 252, 198, 64, 163, 142, 147, 69, 53, 200, 62, 115, 222, 187, 178, 237, 224, 103, 98, 33, 102, 186, 191
  22.         )
  23.     );
  24.     buf :byte;
  25.     besize, i, sor, indx, r:Int64;
  26.     inf, outf :file of byte;
  27.  
  28. function findInArr(arr: array of byte; wat: byte; size: integer) : integer;
  29. var i, ret :integer;
  30. begin
  31.     i := 0;
  32.     ret := -1;
  33.     for i :=0 to size-1 do begin
  34.         if arr[i] = wat then begin
  35.             ret := i;
  36.             break;
  37.         end;
  38.     end;
  39.  
  40.     findInArr := ret;
  41. end;
  42. begin
  43.     assign(inf, paramstr(1));
  44.     assign(outf, paramstr(2));
  45.     reset(inf);
  46.     rewrite(outf);
  47.  
  48.     sor:=0;
  49.     besize := 0;
  50.     i := 0;
  51.     indx := 0;
  52.     r := 0;
  53.     buf := 0;
  54.     besize := FileSize(inf);
  55.  
  56.  
  57.     if paramstr(3) = '1' then
  58.     begin
  59.         while i < besize do begin
  60.  
  61.             blockread(inf, buf, 1, r);
  62.             blockwrite(outf, m[sor, buf], 1, r);
  63.  
  64.             if (sor<2) then
  65.                 inc(sor)
  66.             else
  67.                 sor := 0;
  68.  
  69.             inc(i);
  70.  
  71.         end;
  72.     end;
  73.  
  74.     if paramstr(3)='2' then
  75.     begin
  76.          while i < besize do begin
  77.  
  78.             blockread(inf, buf, 1, r);
  79.             indx := findInArr(m[sor], buf, 256);
  80.             if indx = -1 then begin
  81.                 writeLn('An error occurred during encoding!');
  82.             end;
  83.  
  84.             buf := indx;
  85.  
  86.             if (sor<2) then
  87.                 inc(sor)
  88.             else
  89.                 sor := 0;
  90.  
  91.  
  92.             blockwrite(outf, buf, 1, r);
  93.  
  94.             inc(i);
  95.  
  96.         end;
  97.     end;
  98.  
  99.  
  100.     close(inf);
  101.     close(outf);
  102.  
  103. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement