Update comments.
Add string constant to fix magic string, add assert to make sure the parameter meets expectations.
Improve the techniques for key generation.