Keep the key generation server-side. Even if it's a simple md5 hash, keeping the exact generation details secret is critical. Add a few random characters to whatever hash you do generate, so it won't LOOK like an md5 or sha1 hash.
Of course, then the problem turns into "how do I know the user really won the game"? Decompiling the .swf would let a determined user figure out that you send "won=1" and boom, you get a winning key code back, at which point the game's over, so to speak.
To give you an idea of how hard this can be:
Years ago there was a site that offered dinky flash games you play and win points that you could exchange for prizes. It was horribly sloppy in its coding, to the point where you had to question the sanity of the site's operators. Some of the major flaws:
1) There was a daily survey. A single question with a few choices. They put the point value of the question into the survey form as a hidden value. It was submitted via GET. You could manually build the response and give yourself MAX_INT points once a day, just by doing "response.php?surveyID=XXX&choiceID=YYY&points=4294967295" in the address bar
2) They clued in to that relatively quickly, and fixed the points hole, but for some reason removed the daily limit, so you could submit your answer as many times you wanted for (say) 20 points a pop.
3) After they fixed that up, people moved on to hacking the games - playing the game and winning around would give you (say) 100 points. Here they were a bit smarter at launch and weren't round-tripping the point value through the client. But they forgot to validate the number of times played, which was kept client-side - so you could claim 100 points as many times as you could fire off a POST at their server
4) After fixing that and moving the "times played" count to the server, people just kept their bots submitting the games' particular limit, but submitted bogus claims for EVERY game on the site
5) After they started putting checkpoints into the game (e.g. "tell server level 1 completed", "look, they just finished level 2" etc...) people simply added the checkponit messages to their point stealing bots.
and so on down the road...
If you're going to start doing prize claims with prizes of any sort of value, be aware that you'll probably have many many attempts at sucking your budget beyond bone dry within short order.