Here is a routine in python with an empirical test for uniformity.
First the random generator of ints in the range 1..5:
>>> def r5(): return randrange(5) + 1
>>> bins = dict((i, 0) for i in range(9))
>>> pp(bins)
{0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0}
>>> for i in range(999999): bins[r5()] += 1
>>> pp(bins)
{0: 0, 1: 199752, 2: 200378, 3: 200452, 4: 199580, 5: 199837, 6: 0, 7: 0, 8: 0}
Notice the bin counts for the values 1..5.
THe algorithm used is that if you generate two r5() numbers, in order, then their are 5*5 = 25 possible permutations that all have equal possibility of occurrence. if we take any constant 21 of these permutations, we can see if the perm we generate is in that 21 and turn every three values into one of seven integers to return. If we generate a permutation not in the 21 then we need to get two more r5() values and repeat.
The code for r7 depends on some constants that I have made global for speed:
>>> list5 = [1,2,3,4,5]
>>> perm21 = [(x,y) for x in list5 for y in list5 ][:21]
>>> set21 = set(perm21)
>>> def r7():
r = (6,6)
while r not in set21:
r = (r5(), r5())
return (perm21.index(r) // 3) + 1
>>> bins = dict((i, 0) for i in range(9))
>>> for i in range(999999): bins[r7()] += 1
>>> pp(bins)
{0: 0,
1: 142857,
2: 143558,
3: 143046,
4: 142699,
5: 142786,
6: 142439,
7: 142614,
8: 0}
>>>
Lets try looking at the spread of 10 times the trials:
>>> bins = dict((i, 0) for i in range(9))
>>> for i in range(9999999): bins[r7()] += 1
>>> pp(bins)
{0: 0,
1: 1429821,
2: 1429851,
3: 1427350,
4: 1428478,
5: 1425243,
6: 1429618,
7: 1429638,
8: 0}
Looks OK to me :-)