,Dexter wrote

The first case doesn't work because you don't call TransformFinalBlock.

The second case works fine for me, I get 8 bytes, that is 64 bits.

The third case doesn't work because you flush the write stream but you should close it instead.

I fixed the bug in the third case.

But when I run it I get 16 bytes (128 buts) for both the second and third cases.