This problem is part of a set of problems known as Mental Poker.
There is an excellent and small article by Shamir, Rivest and Adleman that describe a practical way about how to implement such algorithm.
The abstract is gold:
Can two potentially dishonest players play a fair game of poker without using any cards (e.g. over a phone)?
This paper provides the ...