PHP’s “shm_get” function requires an integer semaphore key, which I realise to be a restriction of the underlying OS.
I am using the “sha1” function to hash some user input and using the hash to uniquely identify a number of resulting files and and background processes.
Is there a way to convince shm_get to accept an alphanumeric key or to convert a sha1 hash to an acceptable integer?
You can convert a hexadecimal number into a decimal number by using
hexdec()However if you have got a large number in your hash, this won’t return an integer. But you need an integer. So you might want to cut it apart and only use a part of the hash.