Skip to content
This repository was archived by the owner on Nov 21, 2021. It is now read-only.

sjnam/luajit-xxHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

luajit-xxHash

luajit version for xxHash

Installation

To install luajit-xxHash you need to install xxHash with shared libraries firtst. Then you can install luajit-xxHash by placing lib/resty/xxhash.lua to your lua library path.

Synopsis

local xxhash = require "xxhash"

local f = assert(io.open(filename, r))
local t = f:read("*all")
local x = xxhash.xxh64(t)
print(x)

-- goto start position of the file
f:seek("set", 0)

local xxh = xxhash.new(64)

while true do
   local lines, rest = f:read(1024, "*line")
   if not lines then break end
   if rest then lines = lines .. rest .. "\n" end
   xxh:update(lines)
end
local y = xxh:digest()
print(y)
print("canonical form: ", xxh:canonicalFromHash())

-- check
assert(x == y)

xxh:free()

f:close()

Methods

xx32

syntax: xxhash.xx32(input, seed?)

xx64

syntax: xxhash.xx32(input, seed?)

new

syntax: xxh, err = xxhash.new(bits, seed?)

Creates a xxhash object.

update

syntax: xxh:update(input)

digest

syntax: s = xxh:digest()

canonicalFromHash

syntax: xxh:canonicalFromHash()

The canonical representation uses human-readable write convention, aka big-endian (large digits first).

free

syntax: xxh:free()

Author

Soojin Nam [email protected]

License

Public Domain

About

luajit version for xxHash

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages