如何将32字节的字符缓冲区转换为Lua中的uint64?

我正在编写一个生成基于sha256的唯一ID的机制。我使用:

require 'sha2'

function getUint64ID(callId)
  local minimumValue = 100000000000000000
  local maximumValue = 999999999999999999

  outputHash = sha2.sha256hex(callId)
  print(outputHash .. "\n")

  local c1 = ""

  for a, b in outputHash:gmatch"(%x)(%x)" do
    hexTuple = tostring(a) .. tostring(b)
    intVal   = tonumber(hexTuple, 16)
    c1 = c1 .. string.char(intVal)
  end

  uint64ID = ( minimumValue + ( tonumber(c1) % ( maximumValue - minimumValue + 1 ) ) )

  print('uint64ID:')
  print(string.format("%18.0f",uint64ID))
end

getUint64ID("test")

我在上面的代码中得到以下错误:

stdin:17: attempt to perform arithmetic on a nil value
stack traceback:
    stdin:17: in function 'getUint64ID'
    stdin:1: in main chunk
    [C]: ?

如何将32字节的字符缓冲区(c1)转换为Lua中的uint64数字?

点赞