Feature Request: Random key generation

And because it's impolite to request features without patches, here's a simple if possibly a bit too simple implementation and test.