Encrypt file using VB.NET/Visual Studio 2005
Hi Friends,
I am newbie to the VB.Net and am currently using Visual studio 2005 to Practise with, I am doing it myself through some information from the PDF files that I have taken from my friend, I know VB.Net is very flourish language along with user friendly contents, My friend has also told me that It is also possible to Encrypt the file using VB.Net, so my curiosity wakes up know more about it, so can any there to explain me how we can achieve encryption in VB.Net.
Thanks to those who will help!!
Re: Encrypt file using VB.NET/Visual Studio 2005
The System.Security.Cryptographic namespace in the .NET Framework provides a variety of tools to aid in encryption and in decryption. The CryptoStream class is one of the many classes that is provided. The CryptoStream class is designed to encrypt or to decrypt content as that content is streamed out to a file.
To encrypt a file, follow these steps:
- Run Visual Studio .NET or Visual Studio 2005.
- Create a new console application in Visual Basic .NET or in Visual Basic 2005. A module is created for you, together with an empty Main() procedure.
- Use the Imports statement on the System namespace, the System.Security namespace, the System.Security.Cryptography namespace, the System.Text namespace, and the System.IO namespace. You must do this so that you do not have to qualify declarations from these namespaces later in your code. You must use these statements before any other declarations.
Code:
Imports System
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Runtime.InteropServices
Imports System.Text
For further details on how to Encrypt file please visit to the following site:
http://support.microsoft.com/kb/301070
Re: Encrypt file using VB.NET/Visual Studio 2005
I will suggest some really simple encryption ideas here. One of these is called "exclusive OR" (XOR) encryption. The idea is that you XOR a file byte by byte to produce something that looks like a jumbled mess. But all you have to do is XOR the same file to reverse the encryption. There's an assembly language routine that can implement this method in 42 bytes! Something this simple (and easy to crack) hardly deserves the name encryption.
If you study this program thoroughly, you should have no trouble coding your own string manipulation.
The way this program works is to type a message into a TextBox. The unencrypted and encrypted versions of the message appear simultaneously. When you click the Stash It! button, an encrypted file and a key file are written to disk. Then you can keep the two files seperate and the information in the encypted file will be relatively safe from anyone who doesn't have the key file. To decrypt again, just input both programs into a very simple decryption program that we'll also write here and the original information is recovered.
Re: Encrypt file using VB.NET/Visual Studio 2005
Encryption and Decryption
Here you have good idea about the encryption/decryption process. This block of code has been modified from an article called “Tales from the Crypto” by Billy Hollis. Here is what happens in this procedure:
* Define the enumeration for CryptoAction (encrypt/decrypt).
* Begin with an encrypted/unencrypted file.
* Use a FileStream object to open and read the file.
* Use a CryptoStream object to perform encryption/decryption.
* Use another FileStream object to write the encrypted/decrypted file.
For coding part please visit the following:
http://www.codeproject.com/KB/security/EncryptFile.aspx