The question is roughly the same as the title. Simple hexadecimal conversion seems to only get strings of 0 and 1, not binary data. I hope to know how to write this code. Can I try to use PHP’s built-in functions to achieve it
The purpose is to generate a shorter unique identifier. Previously, md5 was used to determine whether it is duplicated, but the md5 result is a 32-digit hexadecimal string, which is still a bit long, so I want to convert it to a 64-digit string. I don’t know. Are there any mistakes in my thinking?
The question is roughly the same as the title. Simple hexadecimal conversion seems to only get strings of 0 and 1, not binary data. I hope to know how to write this code. Can I try to use PHP’s built-in functions to achieve it
The purpose is to generate a shorter unique identifier. Previously, md5 was used to determine whether it is duplicated, but the md5 result is a 32-digit hexadecimal string, which is still a bit long, so I want to convert it to a 64-digit string. I don’t know. Are there any mistakes in my thinking?
Solved it by myself:
<code>function base64md5 ($str) { return base64_encode(md5($str, 1)); }</code>
ps: It’s roughly the same as above. The code written on the mobile phone is not guaranteed to be correct...
You can use 16-bit md5.