Game Development Reference
In-Depth Information
{
byte[] result = new byte[size];
SHA384Managed sha384 = new SHA384Managed();
sha384.ComputeHash(key);
for (int byteIndex = 0; byteIndex < result.Length; byteIndex++)
{
result[byteIndex] = sha384.Hash[byteIndex];
}
return result;
}
The following generates a correctly sized key using a variation of the code for the
initialization vector generation.
static public byte[] GenerateKey(byte[] key, int size)
{
byte[] result = new byte[size];
SHA384Managed sha384 = new SHA384Managed();
sha384.ComputeHash(key);
int counter = 0;
for (int byteIndex = sha384.Hash.Length - 1;
byteIndex > = (sha384.Hash.Length - size);
byteIndex—)
{
result[counter++] = sha384.Hash[byteIndex];
}
return result;
}
Selecting a Cipher
As discussed previously, there are a few ciphers that can be used for private-key
encryption. They all fundamentally do the same thing, except there are some notable
differences between them in terms of performance, efficiency, and security.
Search Nedrilad ::




Custom Search