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.