I want to convert 160-bit to integer

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:35:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!