问题
I am using SHA1
so i want to convert the output of this SHA1
to integer
回答1:
How about
echo preg_replace("/[^0-9]/i", "", sha1("apikot"));
回答2:
You could represent 160 bits in 5 long ints. That could be an array of 5 long ints, or you could have it be an array of 10 short ints. Are you trying to make it easier to handle than a string of characters/bits?
回答3:
This will convert the sha1sum of /tmp/a to a decimal integer:
$ (echo ibase=16; (cat /tmp/a | sha1sum | tr a-z A-Z | sed s/-// )) | bc
来源:https://stackoverflow.com/questions/1699451/i-want-to-convert-160-bit-to-integer