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.