1
我有一个3GB文件,我需要使用ruby xxhash库进行校验和。该问题我得到一个内存不足的错误。Ruby - XXhash校验和大文件
这是导致该错误代码:
contents = File.read('some_file')
checksum = XXhash.xxh64(contents, 123918230912)
我知道库,如openssl
和digest/sha1
有更新方法,像这样:
checksum = File.open('some_file', "rb") do |io|
dig = Digest::SHA1.new
buf = ""
dig.update(buf) while io.read(4096, buf)
dig
end
但xxhash
似乎不具备这样的方法。我如何能够使用xxhash校验大文件(3GB +)?
帮助赞赏。