You'll probably need to encrypt some data (of your choosing)
To make each key unique use the date and time and millisecond + a phrase
This should generate a fixed length codes when encrypted with a private key, all different
Then all you need to do is decrypt it in Stencyl using a public key and check for the phrase at the end.
All that was just off the top of my head, so there maybe a simpler way. (it may not even be possible in Stencyl.. Not sure)
Or maybe there is a way of generating a code without encryption, some formula, then use the same formula to check it. this would be less secure.