How to create a randomly generated code