I have an array in my PHP application, and I need to develop a function that, given the array and an arbitrary string password, will output a shuffled subset of the large array. The subset and order of the array outputted should be the same every time the same password is used to call the function.
I can generate a pseudo-random number based on the password by taking the integer value of a hash like MD5, but I'm not sure how I can use this to then:
1) Select X (either a fixed number or, preferably, a number chosen by the hash within a given range) random items from the array based on the hash
2) Shuffle/rearrange these items into a subset based on the hash
For my implementation collisions are acceptable, as the array is of a relatively small size. This is a pretty interesting problem - anyone have any idea how to tackle it?