Data Encryption-Case Study

As you might imagine, data traveling on the information highway is vulnerable to spies and potential thieves. It is easy to observe data crossing a network, particularly now that more and more communications involve wireless transmissions.

For example, a person can sit in a car in the parking lot outside any major hotel and pick up transmissions between almost any two computers if that person runs the right sniffing software. For this reason, many applications now use data encryption to protect information transmitted on networks. 

Some application protocols have been updated to include secure versions that use data encryption.Examples of such versions are FTPS and HTTPS, which are secure versions of FTP and HTTP for file transfer and Web page transfer, respectively.

Encryption techniques are as old as the practice of sending and receiving messages. The sender encrypts a message by translating it to a secret code, called a cipher text. At the other end, the receiver decrypts the cipher text back to its original plain text form. Both parties to this transaction must have at their disposal one or more keys that allow them to encrypt and decrypt messages. To give you a taste of this process, let us examine an encryption strategy in detail.

A very simple encryption method that has been in use for thousands of years is called a Caesar cipher. Recall that the character set for text is ordered as a sequence of distinct values. This encryption strategy replaces each character in the plain text with the character that occurs a given distance away in the sequence. For positive distances, the method wraps around to the beginning of the sequence to locate the replacement characters for those characters near its end. For example, if the distance value of a Caesar cipher equals five characters, the string “invaders” would be encrypted as “nsafijwx.” To decrypt this cipher text back to plain text, you apply a method that uses the same distance value but looks to the left of each character for its replacement. This decryption method wraps around to the end of the sequence to find a replacement character for one near its beginning.

The next  Python scripts implement Caesar cipher methods for any strings that contain lowercase letters and for any distance values between 0 and 26. Recall that the ord function returns the ordinal position of a character value in the ASCII sequence, whereas chr is the inverse function.

#encryption with Caesar Cipher
plainText=input("Enter a one-word,lowercase message:")
distance=int(input("Enter the distance value: "))
cipherText=""
for ch in plainText:
  ordValue=ord(ch)
  cipherValue=ordValue+distance
  if cipherValue>ord('z'):
    cipherValue=ord('a')+distance-(ord('z')-ordValue+1)
  cipherText+=chr(cipherValue)
print("Cipher text is:",cipherText)

#decryption with Caesar Cipher
distance=int(input("Enter the distance(key) value for decryption:"))
plainText=""
for ch in cipherText:
     ordValue=ord(ch)
     cipherValue=ordValue-distance
     if cipherValue<ord('a'):
          cipherValue=ord('z')-distance-(ord('a')-ordValue+1)
     plainText+=chr(cipherValue)
print("Plain text after decryption is:",plainText)

output:
Enter a one-word,lowercase message:binu
Enter the distance value: 5
Cipher text is: gnsz
Enter the distance(key) value for decryption:5
Plain text after decryption is: binu


These scripts could easily be extended to cover all of the characters, including spaces and punctuation marks.Although it worked reasonably well in ancient times, a Caesar cipher would be no match for a competent spy with a computer. Assuming that there are 128 ASCII characters, all you would have to do is write a program that would run the same line of text through the extended decrypt script with the values 0 through 127, until a meaningful plain text is returned. It would take less than a second to do that on most modern computers. The main shortcoming of this encryption strategy is that the plain text is encrypted one character at a time, and each encrypted character depends on that single character and a fixed distance value. In a sense, the structure of the original text is preserved in the cipher text, so it might not be hard to discover a key by visual inspection.

A more sophisticated encryption scheme is called a block cipher. A block cipher uses a plaintext character to compute two or more encrypted characters, and each encrypted character is computed using two or more plaintext characters.This is accomplished by using a mathematical structure known as an invertible matrix to determine the values of the encrypted characters. The matrix provides the key in this method. The receiver uses the same matrix to decrypt the cipher text. The fact that information used to determine each character comes from a block of data makes it more difficult to determine the key.

Comments

Popular posts from this blog

Programming in Python CST 362 KTU CS Sixth Semester Elective Notes

Image Processing

Turtle Graphics