Click here to Skip to main content
Licence CPOL
First Posted 23 Apr 2002
Views 105,815
Downloads 3,355
Bookmarked 19 times

Simple Encryption

By | 23 Apr 2002 | Article
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sumesh Ram



United States United States

Member

Freelance Programmer/Student

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
NewsTwo other related encryption articles in CodeProject ... PinmemberTony Selke6:52 27 Sep '07  
GeneralImage Encryption PinmemberApr Jais0:34 12 Jan '06  
GeneralAnalizing encryption PinPopularmemberGabriel 25:20 3 May '02  
GeneralXOR cipher PinmemberBlake Coverett22:11 24 Apr '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 24 Apr 2002
Article Copyright 2002 by Sumesh Ram
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid