(regarding symmetric encryption, such as AES/Rijndael, Blowfish, Twofish…)
Question:
If we’re receiving a key from someone else, how do we set our secret key to be that. Until now we’ve just been using the crypt.GenerateSecretKey("***") method. But now we want to set the key to one sent by someone else. What for should we get them to send it in?
Answer:
Encryption algorithms use *binary* secret keys. For a N-bit algorithm, the key is N bits. So… for 128-bit encryption, the binary secret key is 16 bytes (8 bits/byte * 16 = 128 bits). If you intend to use password strings, the string must be hashed to a binary byte array that is the correct length. The crypt.GenerateSecretKey method does this — it hashes a string and returns a binary secret key (byte array) of the correct length. If you need to interoperate with other systems, you should set the SecretKey property directly (the SecretKey property is a byte array representing the raw binary secret key). If you want to use password strings, you might use Chilkat Crypt’s hashing methods to hash your string to construct a key of the appropriate length.