Cryptography

This chapter describes problems in cryptography. The first few problems ask you to use cryptographic systems that were once state-of-the-art but that are now insecure. They are purely for fun and are of historical significance. Later problems use modern, secure techniques, such as the .NET Framework's cryptographic library, to build secure programs.

When studying cryptography, it's useful to know a few basic terms. A key is a piece of secret information that you can use to encrypt and decrypt messages. Sometimes, a password is a key. Other times, a password is used to generate a key in a format suitable for use by a particular encryption algorithm. A message that is not encrypted is called plaintext. The encrypted version of plaintext is called ciphertext.

Traditionally, plaintext and ciphertext are written in five-letter groups of uppercase letters without punctuation or spaces, at least for older encryption systems such as the Caesar substitution and Vigenère ciphers. For example, the message, This is the secret message, would be written in plaintext as THISI STHES ECRET MESSA GE, and might be encrypted as WKLVL VWKHV HFUHW PHVVD JH. An N-gram is a sequence of N contiguous pieces of text or speech, so I call these groups five-grams. More modern systems encrypt and decrypt streams of bytes that can contain just about anything, including images, documents, and databases. In those systems, it doesn't make much sense to represent messages in five-grams.

Like most of the other topics covered in this book, cryptography is a huge subject, so this chapter covers only a tiny part of it. For more information, consult a book about cryptography, such as Bruce Schneier's excellent book, Applied Cryptography: Protocols, Algorithms and Source Code in C (John Wiley & Sons, 2015). You can also search the internet for general information and specific examples. For instance, Wikipedia has an overview at https://en.wikipedia.org/wiki/Cryptography, and Khan Academy has a course about cryptography at https://www.khanacademy.org/computing/computer-science/cryptography.

Most of the example solutions in this chapter use the .NET Framework's cryptography namespace, so you may want to add the following using directive to your code files:

using System.Security.Cryptography;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset