I would like to know, can someone post a working example of converting a BAM file to CRAM and BAM again? 

I tried samtools, cramtools but each time, the BAM tags get mangled. Can someone show me how to get:

    samtools view file1.bam | md5sum 
    ed071dff8d60c74eefd1d14eb1f4bb21

then convert to CRAM, back to bam file2.bam such that:

    samtools view file2.bam | md5sum 
    ed071dff8d60c74eefd1d14eb1f4bb21

Sorry if this is trivial but I have spent a few hours on this.
I think the source of the problem is that the BAM specification does not require or prescribe an order to the tags, hence these can be reordered and still represent the same information. I would contact the SAM developers and see what could be done about this:

https://github.com/samtools/