【发布时间】:2018-08-31 05:54:16
【问题描述】:
我需要将 sip callId(例如 1097074724_100640573@8.8,8.8)字符串转换为 requestId,并且我正在使用 sha1 摘要来获取哈希。由于内部兼容性,我需要将此十六进制转换为 uint64_t:
--
-- Obtain request-id from callId
--
-- Returns hash
--
function common_get_request_id( callId )
local command = "echo -n \"" .. callId .. "\" | openssl sha1 | sed 's/(stdin)= //g'"
local handle = assert( io.popen( command, "r" ) )
local output = handle:read( "*all" )
local outputHash = string.gsub(output, "\n", "") -- strip newline
handle:close()
-- How to convert outputHash to uint64?
end
我不确定 Lua 是否支持 uint64。还有,怎么转换?
【问题讨论】:
-
SHA1 生成 160 位,而不是 64 位。你想要什么转换?