Game Development Reference

In-Depth Information

The symmetric encryption algorithms provided by the .NET Class Framework are

described in Table 16.3.

Table 16.3
.NET Symmetric Encryption Algorithms

Algorithm

Description

DES

This symmetric algorithm, also known as the Digital Encryption Standard, has

existed for quite some time and is fairly weak by current standards. The DES

algorithm was specifically designed to be efficient when implemented in

hardware and inefficient when implemented in software. Because of its design,

this algorithm is relatively slow compared to more modern algorithms. Another

limitation is the short block and key sizes, available only in a 64-bit flavor.

Triple DES

This symmetric algorithm is basically a strengthened version of DES, offering

stronger keys of 128-bit and 192-bit. Triple DES runs the DES algorithm over the

input data three times, resulting in an algorithm that is stronger but three times

slower than DES.

RC2

This symmetric algorithm is fairly good, and it performs more than twice as fast

as DES when implemented in software. The 64-bit block size is relatively small,

but at least the algorithm supports key lengths of 40 to 128 bits in 8-bit

increments.

Rijndael

This symmetric algorithm, also known as the Advanced Encryption Standard

(AES), supports block and key sizes of 128, 192, and 256 bits.

While scrutinized for being new and not yet standing the test of time, the

Rijndael algorithm has become a U.S. Federal Government standard, and is

the recommended symmetric encryption algorithm to use whenever possible.

ICryptoTransform Interface

All symmetric encryption implementations provided in the .NET Class

Framework implement the
ICryptoTransform
interface, which provides a uniform

way to encrypt and decrypt data independently of the selected cipher.

Table 16.4 describes the members of the
ICryptoTransform
interface.

Since all symmetric algorithms inherit from this interface, encryption and decryp-

tion is accomplished using the same calls independently of the cipher used. The

following code shows how to encrypt or decrypt binary data of arbitrary length.