I'm using the following code to genrate a simple UID for my app:
private function _createUid() {
$bytes = random_bytes(128);
$uid = bin2hex($bytes);
return $uid;
}
By doing this, the result of _createUid()
will be a 256 character string. My question is, will this string always be 256
characters if run on the same server, I'm aware of some differences on different servers. Also, is one byte equal to two characters?
Any help would be great, thanks!
In hex a byte is always expressed as 2 characters.
Hexadecimal representation of a byte is a sequence of two character pairs. The first character represents the most significant 4 bits and the second character represents the least significant 4 bits of a byte.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With