Code sharing between co-authors During a collaborative experimental project in my PhD, I developed a rather intricate simulation + data processing tool. The work was published with myself as the lead author. One of the collaborators, who is located in a different country, was keen on extending that work and, based on ideas and inputs during the course of the project, she got one of her students to prepare the experiment at their end. (Meanwhile, I finished my PhD and am now working as a Postdoc at a different group).

Recently, they got their first results and now to bring this study to a conclusion, the collaborator requested me to process their experimental data through that tool I had developed. I haven't been offered an authorship yet but chances are fair that I would be if the tool gives publication-worthy results (As also mentioned above: I have already contributed a bit in this study through ideas). My question however is, in the event I am offered a co-authorship, am I obliged to also share the entire code with them? 

While I am certainly open to giving them a gist of how the tool works (or to even get it lightly reviewed) via code snippets, screenshots etc., I am wary of simply handing them all the files. This is due to the fact that we had had some authorship issues with the collaborator in the past (though I wasn't directly involved at that time). If they have the files, there is a good probability that they would obtain the results themselves, publish them, with my name -- at the very best -- being in the acknowledgements section. 

Additional info in response to some answers: Certain parts of the code are generic and could be useful to the broad community. Being pro open source myself, I intend to release those parts publicly soon. The other part of the code is very specific to the current work and would be of use to only a handful of people, including the collaborator's group.
I will give the answer I have given a million times already on this forum: Communicate. 

If you're unsure whether or not you processing the data will yield a co-authorship, write an email asking exactly this before you do the data processing. If the other side is an experienced researcher, then they will understand that as a postdoc you have many obligations to juggle and that you need to spend your time on things that will yield publications.

If you're unsure whether or not you will be expected to share your code, write an email asking exactly this before you start working with them. They may ask for it, and in that case you will have to discuss with them under what conditions you would be willing to do that. Or they may not even want your code and simply be happy to rely on you this time and in future times to do the data analysis in return for co-authorship.

In both cases, you can spend your day worrying and speculating, but you will never know the answer unless you simply ask what's on your mind. Communicate!