Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif /img/help/prev.gif /img/help/next.gif

 

Encrypting a file

 


 

EasyCompression Library provides a file stream interface with TECLFileStream class that can be easily used to compress/encrypt and decompress/decrypt a file.

 

Encrypting a file.

To encrypt a file to file you need to perform the following 3 steps:

  1. Create an instance of TECLFileStream for the destination encrypted file with not blank Password and with CompressionLevel parameter not equal to eclNone value, i.e. with one of the compression modes.
  2. Call LoadFromFile method of TECLFileStream to load, compress and encrypt source file.
  3. Free the TECLFileStream object to close encrypted file.
  4.  

    Example:

    var

    CompFS: TECLFileStream;

    begin

    CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, 'password', zlibFastest);

    CompFS.LoadFromFile('c:\test.txt');

    CompFS.Free;

    end;

     

    Decrypting a file.

    To decrypt and decompress a file to file you need to perform the following 3 steps:

    1. Create an instance of TECLFileStream for the source encrypted and compressed file with two parameters in constructor: FileName and Mode.
    2. Call SaveToFile method of TECLFileStream to decrypt and decompress data and save to the destination file.
    3. Free the TECLFileStream object to close encrypted file.
    4.  

      Example:

      var

      CompFS: TECLFileStream;

      begin

      CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmOpenRead or fmShareDenyNone, 'password');

      CompFS.SaveToFile('c:\test_decomp.txt');

      CompFS.Free;

      end;

       

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Mar 29, 2024