Note: this should only be used for reducing a string's character set range.
It is not for use with arbitrary data since leading 0 bytes will be dropped.
Random generates a random base62-encoded string.
If truncate is true, the result will be a string of the requested length.
Otherwise, it will be the encoded result of length bytes of random data.