I am using:
random_bytes(30);
to generate a random string for my program. This string is then stored in a mysql database. However, when I run the function, I get an output such as
T�Ը�@(���m
which includes unreadable characters. When I then try to store it in my database, the � characters are not stored and so this means that the string is not properly preserved.
How can I make it so that it returns a string with only readable characters that will not be lost in my mysql database?
Thanks!
random_bytes generates an arbitrary length string of cryptographic random bytes that are suitable for cryptographic use, such as when generating salts, keys or initialization vectors. use like this
$bytes = random_bytes(5);
echo bin2hex($bytes);
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