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

Fixes #4114.

Needs review.
This one is really interesting, as it would allow creating a key representation of arbitrary character specifictaion: http://php.net/manual/en/function.base-convert.php#106546