Added Security::generateRandomHexKey(), used it for various tokens and default key generation

Fixes #4114.

Needs review.
The parameter is not about characters but about bytes. Trimming doesn't sound good and may lead to unexpected consequences.