Game Development Reference
In-Depth Information
Table 16.4 Members of the ICryptoTransform Interface
Member Name
Description
CanReuseTransform
This property indicates whether the current transform can be
reused or not. All ciphers in the .NET Class Framework always
return true.
CanTransformMultipleBlocks
This property indicates whether or not multiple blocks can be
transformed in a single call to either TransformBlock or
TransformFinalBlock . All ciphers in the .NET Class
Framework always return true.
InputBlockSize
This property indicates the size of the input blocks, which will
always be identical to the OutputBlockSize . The return
value is dependent on the value of the BlockSize property
set in the cipher.
OutputBlockSize
This property indicates the size of the output blocks, which
will always be identical to the InputBlockSize . The return
value is dependent on the value of the BlockSize property
set in the cipher.
TransformBlock
This method encrypts or decrypts one or more blocks before
the end of the message.
TransformFinalBlock
This method encrypts or decrypts one or more blocks at the
end of the message. Ending blocks must be transformed
differently from other blocks due to padding issues.
using System.Security.Cryptography;
static public byte[] EncryptMessage(SymmetricAlgorithm cipher,
byte[] key,
byte[] plainText)
{
ICryptoTransform transform = cipher.CreateEncryptor(GenerateKey(key, 16),
GenerateIV(key, 16));
byte[] result = transform.TransformFinalBlock(plainText, 0, plainText.Length);
return result;
}
static public byte[] DecryptMessage(SymmetricAlgorithm cipher,
byte[] key,
byte[] cipherText)
{
ICryptoTransform transform = cipher.CreateDecryptor(GenerateKey(key, 16),
GenerateIV(key, 16));
Search Nedrilad ::




Custom Search