This sounds like the principle of double effect. This is when a person takes an action that has two consequences, one positive, and one negative. There are four conditions that are generally needed for the action to be considered moral:
- The action itself must be good or neutral. Developing code for anonymity meets this condition.
- The bad effect must not me the means by which the good effect is achieved. Anonymity (the good effect) is not achieved by people committing crimes. So again, this is fine.
- The intention must be the good effect, not the bad effect. You clearly don't intend for people to abuse your code, and want them to use it for good. So this is okay, again.
- The good effect must be at least as important as the bad effect. This is the only one I can see being even questionable in your situation.
In other words, the final question is: Do you think that, overall, more good will be done with software for anonymity than harm? If so, you are in the right to continue to develop it. Personally, I think software for anonymity probably does more good than ill, but I'm no expert.
I don't think the "why not, if you don't, someone else will do it" argument holds water. If developers hold themselves to high standards of ethics, unethical software will be written more slowly and ethical software to defend against it will have a better chance of doing its job. Also, writing unethical code numbs us so we are less likely to recognize future ethical dilemmas and slowly degrades our personal dignity. However, I don't think that this is a case where you need to be concerned; you will be working to make this software for good, with good reason to think it will do primarily good. You are in the right for the same reason that a person making a taser designed for self-defense is in the right. Sure, it could be misused - but in general, it is a tool designed for good.