The goal is to store the hash on a mysql database, using INT (not BIGINT or MEDIUMINT).
md5('string', true)
returns binary data, 16 bytes of hash. I thought i could grep the first 4 bytes and convert it to an INT(32bit/4bytes) integer, but i don't know how to do it.
What do you suggest? Thanks.
$int = bindec(substr(md5('string', true),0,4))
or$int = hexdec(substr(md5('string'),0,8))
- but, fairly obviously, this does not store the whole hash, only the first 4 bytes of it. – DaveRandom Dec 15 '11 at 13:42bindec
won't work (hexdec
does). – hakre Dec 15 '11 at 13:54