Does it need to be "random"? Because each response gets an ID given by Limesurvey, the SAVEDID. You can access/display it via Expression Manager using this:
Of course you can create a random code as well, but as with everything random, there is a chance that you get dublicates. Of course with a long random number the chances get smaller, but the chance is still there.
Ideally, I would probably work with a combination of both, e.g. create a random number and add it at the beginning or the end of the SAVEDID and save this into an equation question.
When the person comes and gives you the code, you'd have to search this equation question for the right code.
There was a discussion about this in the forum already, with code examples. If I recall right, someone even created a plugin.