Possible Duplicate:
Two untrusted party want to exchange data: how to insure each one gets the data it needs?

I am trying to come up with what could maybe be a novel algorithm for an application I am writing.

Alice has file A and Bob has file B. Alice wants B and Bob wants A. Each party is untrustworthy and will try to rip off the other party. Each party has an hash of the file it wants (therefore they can tell if the other party sends junk).

How can I make an algorithm to exchange A and B, where it is not possible for the parties to rip off the other party during the exchange.