1. Computing

File Encrypt / Decrypt

Fancy Delphi Application Contest Entry #31 by Eduardo Teixeira

From , former About.com Guide

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.

©2013 About.com. All rights reserved.