1. Home
  2. Computing & Technology
  3. Delphi Programming

File Encrypt / Decrypt
Fancy Delphi Application Contest Entry #31 by Eduardo Teixeira

By Zarko Gajic, About.com

File Encrypt / Decrypt - Fancy Delphi Application Contest Entry #31

File Encrypt / Decrypt - Fancy Delphi Application Contest Entry #31

Looking for an easy way to encrypt and protect your data? How about one built with Delphi including full source code?

A great idea for the Fancy Delphi Application Contest ;-)

File Encryptor / Decryptor

Encryption is the process of converting a file into a format that cannot be read by the applications set up to open the file. To remove the encryption you decrypt.

To encrypt or decrypt a file, simply click on the "Open" button, select an integer "masking" value and then click "(En/De) Crypt File". This little tool is ideal for offices that need to keep important documents secure.

"File Encryptor / Decryptor" was submitted by Eduardo Teixeira.

Here's a code section of this magical tool:

procedure TEnDeCrypt.EnDecryptFile(pathin, pathout: string; Chave: Word) ;
var
  InMS, OutMS: TMemoryStream;
  cnt: Integer;
  C: byte;
begin
  InMS := TMemoryStream.Create;
  OutMS := TMemoryStream.Create;
  try
    InMS.LoadFromFile(pathin) ;
    InMS.Position := 0;
    for cnt := 0 to InMS.Size - 1 do
      begin
        InMS.Read(C, 1) ;
        C := (C xor not (ord(chave shr cnt))) ;
        OutMS.Write(C, 1) ;
      end;
    OutMS.SaveToFile(pathout) ;
  finally
    InMS.Free;
    OutMS.Free;
  end;
end;

Do you have a FDA(C)? Submit your Delphi code to the Fancy Delphi Application Contest.

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Source Code Projects
  5. File Encrypt / Decrypt - Fancy Delphi Application Contest Entry #31

©2009 About.com, a part of The New York Times Company.

All rights reserved.