Previously, when iterating over bytes of the generated salt to construct a hex string, only one character would be outputted when the byte is less than 0x10. Meaning that for a 16 byte salt, the hex string might be less than 32 characters and collisions would occur.
Backport of core PR14742
https://github.com/bitcoin/bitcoin/pull/14742/files
Depends on D3780.