The two two solutions above assume all possible combinations of all possible cards without regards for duplication or order. That is, you have a unique identifier allocated for {i,i} which is not a possible hand, and you get two different identifiers for {i,j} and {j,i} which in fact are the same hands.
Assume a deck of 6 cards for each for easy visualization; the concept extends to any size. If you just take the above solutions, you get the following matrix of enumerated hards (x- and y-axes fo the table are the cards i and j, respectively):
0 1 2 3 4 5
5 6 7 8 9 10
10 11 12 13 14 15
15 16 17 18 19 20
20 21 22 23 24 25
25 26 27 28 29 30
As you can see, the diagonals have a unique value for impossible hands, and the upper-right and lower-left triangular parts also have unique values for the same hands.
What you want is the following matrix:
- 0 2 5 9 14
- - 1 4 8 13
- - - 3 7 12
- - - - 6 11
- - - - - 10
- - - - - -
where - indicates a don't care-value because those hands are either impossible or already represented in the upper-right triangle.
Given two card indices {i,j}, the formula 0.5*i*i + 0.5*i - j - 1 gives you those values, assuming that i and j are integers and that j<i. The formula is independent on the number of cards. It should be possible to solve this for {i,j} given a hand index. It is a single equation with two unknowns, and the quadratic equation generally have two solutions as well, but I believe there is only one solution given the constraints that i and j are integers, and that 0<=j<i<52.
But given the very limited number of hands, a table with pre-coded hands may be feasible. In that case, just search the table for the combination of two cards and likewise look up the table index and read which two cards it represents.