Skip to content

Commit

Permalink
perl implementation of crc32 algorithm added
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Berezhnoy committed Nov 30, 2015
1 parent 24a5091 commit f13da35
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions perl_crc32.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if ffi == nil then
if require == nil then
error('You must restart tarantool')
end
ffi = require('ffi')
end

ffi.cdef[[
unsigned perl_crc32(const char *key, unsigned len);
]]

local libperlcrc32 = ffi.load("perlcrc32")

function perl_crc32(key)
if type(key) ~= "string" then
error("String key is expected in perl_crc32: '" .. key .. "'")
end

return libperlcrc32.perl_crc32(key, #key)
end

0 comments on commit f13da35

Please sign in to comment.