Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simple Encryption

0.00/5 (No votes)
23 Apr 2002 1  
Sometimes we may desire to hide our file contents from others. One of the possible ways is by encrypting these files. Here, a simple encryption technique is used (in VB - the same technique can be implemented in C also.)

Introduction

What does the code DO? Sometimes we may desire to hide our file contents from others. One of the possible ways is by encrypting these files. Here, a simple encryption technique is used (in VB - the same technique can be implemented in "C" also.)

Program Flow Explained

  • Open the File to be encrypted for Binary Access Read (say source file)
  • Open a temporary file where encrypted data is stored for Binary Access Write (say destination file)
  • Loop through the source file byte by byte
  • For each byte read from the file, complement the data (Using Not operator (in C we have to use "~" operator)
  • Write the complemented data to destination file
  • Delete the source file
  • Rename destination file as source file (now encryption is over)

How to Decrypt?

Since we have complemented and saved byte by byte, simply complement it again for reproducing the original file (i.e.: The same code can be used for both encryption and decryption).

The source code can be found at the top of this article.

History

  • 23rd April, 2002: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here