public byte[] EncryptData(byte[] UnencryptedData)
{
int count = UnencryptedData.Length;
int full = (count / BlockSizeByte) * BlockSizeByte;
int rem = count - full;
int total = full + BlockSizeByte;
byte[] output = new byte[BlockSizeByte + total];
_enc_iv.CopyTo(output, 0);
_enc.TransformBlock(UnencryptedData, 0, full, output, BlockSizeByte);
Buffer.BlockCopy(UnencryptedData, full, _temp, 0, rem);
byte padding = (byte) (BlockSizeByte - rem);
for(int i = rem; i < BlockSizeByte; i++) {
_temp[i] = padding;
}
_enc.TransformBlock(_temp, 0, BlockSizeByte, output, output.Length - BlockSizeByte);
_enc_iv.CopyTo(output, 0);
Buffer.BlockCopy(output, output.Length - BlockSizeByte, _enc_iv, 0, BlockSizeByte);
return output;
}