public void Encrypt(byte[] message) { Data data = new Data(message, _blockSize); for (int i = 0; i < data.NumberOfBlocks; ++i) { try { byte[] block = data.GetNBlock(i); block = InitialPermutation(block); for (byte round = 0; round < 16; ++round) { byte[] subkey = _key.Subkeys.ElementAt(round); byte[] left = block.Take(4).ToArray(); byte[] right = block.Skip(4).Take(4).ToArray(); block = Round(left, right, subkey); } block = ReverseLeftAndRight(block); block = ReversedInitialPermutation(block); EncryptedMessage = EncryptedMessage.Concat(block).ToArray(); } catch { throw; } } }
//Return a byte array of the encrypted message and encrypted symmetric key. public byte[] EncryptedDataKeyPair() { return(EncryptedMessage.Concat(EncryptedSymmetricKey).ToArray()); }