Encrypting

Team Fly 

Page 143

Just send the hash value along with the file and the recipient can hash the file on their end to see if the hash values match, demonstrating that the file has not been altered during transmission.

Encrypting

The goal of encryption is to rearrange information so that it makes no sense to an intruder. Rearrange, not destroy. You don't want to so completely disturb the original information (the plaintext) that it is impossible to restore. You don't want to reduce the data to a fuming wreck.

However, precisely because the encrypted information (the ciphertext) is restorable, the wrong people—the intruder—can potentially restore it, read it, and make use of it. Intruder or Eve are the traditional names for people who intercept messages—Eve for evesdropper.

DES is the most popular strong encryption in use today to encrypt large amounts of data. Everything from money wire transfers to secret government communications are transmitted after having been encrypted via DES.

The government went to IBM in the early seventies and asked them to come up with an encryption standard for government and business communications. The government wanted the system to be computer-based and impossible to break, and they got their wish in 1976. Ever since, it's been the standard. Some observers say that DES has been cracked, but others disagree. In any case, it would require tremendous multi-processing power—many tens of thousands of personal computers working in tandem—to hope to crack a DES encrypted message. (Some experts suggest that the government has such power, but prefers to keep DES the standard because they want to be able to read messages and keep track of things.)

If you feel that your information is likely to draw attention from the government or 90,000 personal computer users who will gang together to focus on your secrets, .NET offers even stronger encryption functions. You might be particularly interested in the asymmetric public key system (RSA) described at the end of this chapter. The problem with asymmetric systems is that they are less efficient, slower. Some people advocate dividing the job into two processes: Using asymmetric encryption to transmit keys (which are short, compared to the size of most messages), then using DES to encrypt the messages.

Or, if you just want a beefier version of DES, .NET offers a couple of other algorithms, including TripleDES. How much slower is TripleDES than DES? Three times. But unless your messages are huge or your computer is slow, you probably won't be bothered by the speed issue.

There are many dozens of ways to encrypt files in .NET. Listing 6.3 illustrates one way to encrypt and decrypt a file using the DES algorithm.

LISTING 6.3: ENCRYPTION AND DECRYPTION A FILE WITH DES

Private Sub Form1_Load(ByVal sender As System.Object, _
 ByVal e As System.EventArgs) Handles MyBase.Load
        encrypt()
        decrypt()
End Sub

Public Sub encrypt()

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net