Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.01.30;
Скачать: CL | DM;

Вниз

Word шифровка   Найти похожие ветки 

 
Silver   (2004-04-17 06:32) [0]

Здравствуйте.
Помогите пожайлуста как шифрануть Word"овский файл. Тоесть надо сделать так зашифровать его , а потом в Delphi через оле открыть уже расшифрованным.
Делаю так ничего толкового неполучается.

unit EncodStr;

interface

uses
 Classes;

type
 TEncodedStream = class (TFileStream)
 private
   FKey: Char;
 public
   constructor Create(const FileName: string; Mode: Word);
   function Read(var Buffer; Count: Longint): Longint; override;
   function Write(const Buffer; Count: Longint): Longint; override;
   property Key: Char read FKey write FKey default "A";
 end;

implementation

constructor TEncodedStream.Create(
 const FileName: string; Mode: Word);
begin
 inherited Create (FileName, Mode);
 FKey := "A";
end;

function TEncodedStream.Write(const Buffer;
  Count: Longint): Longint;
var
 pBuf, pEnc: PChar;
 I, EncVal: Integer;
begin
 // allocate memory for the encoded buffer
 GetMem (pEnc, Count);
 try
   // use the buffer as an array of characters
   pBuf := PChar (@Buffer);
   // for every character of the buffer
   for I := 0 to Count - 1 do
   begin
     // encode the value and store it
     EncVal := ( Ord (pBuf[I]) + Ord(Key) ) mod 256;
     pEnc [I] := Chr (EncVal);
   end;
   // write the encoded buffer to the file
   Result := inherited Write (pEnc^, Count);
 finally
   FreeMem (pEnc, Count);
 end;
end;

function TEncodedStream.Read(var Buffer; Count: Longint): Longint;
var
 pBuf, pEnc: PChar;
 I, CountRead, EncVal: Integer;
begin
 // allocate memory for the encoded buffer
 GetMem (pEnc, Count);
 try
   // read the encoded buffer from the file
   CountRead := inherited Read (pEnc^, Count);
   // use the output buffer as a string
   pBuf := PChar (@Buffer);
   // for every character actually read
   for I := 0 to CountRead - 1 do
   begin
     // decode the value and store it
     EncVal := ( Ord (pEnc[I]) - Ord(Key) ) mod 256;
     pBuf [I] := Chr (EncVal);
   end;
 finally
   FreeMem (pEnc, Count);
 end;
 // return the number of characters read
 Result := CountRead;
end;

end.


unit EncForm;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 StdCtrls, ExtCtrls;

type
 TFormEncode = class(TForm)
   Memo1: TMemo;
   Memo2: TMemo;
   OpenDialog1: TOpenDialog;
   SaveDialog1: TSaveDialog;
   Panel1: TPanel;
   BtnLoadPlain: TButton;
   BtnSaveEncoded: TButton;
   BtnLoadEncoded: TButton;
   Splitter1: TSplitter;
   procedure BtnSaveEncodedClick(Sender: TObject);
   procedure BtnLoadEncodedClick(Sender: TObject);
   procedure BtnLoadPlainClick(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 FormEncode: TFormEncode;

implementation

{$R *.DFM}

uses
 EncodStr;

procedure TFormEncode.BtnSaveEncodedClick(Sender: TObject);
var
 EncStr: TEncodedStream;
begin
 if SaveDialog1.Execute then
 begin
   EncStr := TEncodedStream.Create(
     SaveDialog1.Filename, fmCreate);
   try
     Memo1.Lines.SaveToStream (EncStr);
   finally
     EncStr.Free;
   end;
 end;
end;

procedure TFormEncode.BtnLoadEncodedClick(Sender: TObject);
var
 EncStr: TEncodedStream;
begin
 if OpenDialog1.Execute then
 begin
   EncStr := TEncodedStream.Create(
     OpenDialog1.FileName, fmOpenRead);
   try
     Memo2.Lines.LoadFromStream (EncStr);
   finally
     EncStr.Free;
   end;
 end;
end;

procedure TFormEncode.BtnLoadPlainClick(Sender: TObject);
begin
 if OpenDialog1.Execute then
   Memo1.Lines.LoadFromFile (
     OpenDialog1.FileName);
end;

end.


Да и есчеё кто знает как при момощи Delphi открыть вордовский файл, что бы на форме отображалась только стараница безовсяких панелей инструментов.

Испльзую Delphi 7.

Заранее спасибо.


 
VMcL ©   (2004-04-17 14:57) [1]

>как при момощи Delphi открыть вордовский файл, что бы на форме отображалась только стараница

TOleContainer
?


 
Silver   (2004-04-17 18:40) [2]

А как шифрануть Вордовский файл?????????????



Страницы: 1 вся ветка

Текущий архив: 2005.01.30;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.024 c
1-1105891337
Qu
2005-01-16 19:02
2005.01.30
Определение цвета?


8-1097993332
Ozone
2004-10-17 10:08
2005.01.30
3D MAX + Delphi


14-1105635943
Tankist
2005-01-13 20:05
2005.01.30
Все религии неверные?


9-1098022792
Вась-вась
2004-10-17 18:19
2005.01.30
Помогите, пожалуйста, понять стратегии!!!


3-1104255664
Aleksandr.
2004-12-28 20:41
2005.01.30
Как при помощи IbClientDataSet файловые данные "закатать"...?