<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://zh.enter-politics.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3ACrc32lua</id>
	<title>模块:Crc32lua - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://zh.enter-politics.com/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3ACrc32lua"/>
	<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;action=history"/>
	<updated>2026-04-11T21:59:03Z</updated>
	<subtitle>本wiki的该页面的版本历史</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9944&amp;oldid=prev</id>
		<title>白龙：导入2个版本</title>
		<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9944&amp;oldid=prev"/>
		<updated>2022-07-11T10:56:10Z</updated>

		<summary type="html">&lt;p&gt;导入2个版本&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2022年7月11日 (一) 10:56的版本&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key mw-wiki2_:diff::1.12:old-224:rev-9944 --&gt;
&lt;/table&gt;</summary>
		<author><name>白龙</name></author>
	</entry>
	<entry>
		<id>https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=224&amp;oldid=prev</id>
		<title>One-Six：导入1个版本：受托导入数个模板；本次导入Infobox，来源为ZhWP</title>
		<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=224&amp;oldid=prev"/>
		<updated>2020-06-01T00:55:14Z</updated>

		<summary type="html">&lt;p&gt;导入1个版本：受托导入数个模板；本次导入Infobox，来源为ZhWP&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2020年6月1日 (一) 00:55的版本&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key mw-wiki2_:diff::1.12:old-223:rev-224 --&gt;
&lt;/table&gt;</summary>
		<author><name>One-Six</name></author>
	</entry>
	<entry>
		<id>https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=223&amp;oldid=prev</id>
		<title>zhwp&gt;Xiplus：已保护“模块:Crc32lua”：高风险模板（[编辑=仅管理员]（无限期）[移动=仅管理员]（无限期））</title>
		<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=223&amp;oldid=prev"/>
		<updated>2019-02-26T15:10:54Z</updated>

		<summary type="html">&lt;p&gt;已保护“&lt;a href=&quot;/wiki/%E6%A8%A1%E5%9D%97:Crc32lua&quot; title=&quot;模块:Crc32lua&quot;&gt;模块:Crc32lua&lt;/a&gt;”：高风险模板（[编辑=仅管理员]（无限期）[移动=仅管理员]（无限期））&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2019年2月26日 (二) 15:10的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;zh&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;（没有差异）&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>zhwp&gt;Xiplus</name></author>
	</entry>
	<entry>
		<id>https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9943&amp;oldid=prev</id>
		<title>2014年11月25日 (二) 14:49 wiki:zh&gt;Liangent</title>
		<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9943&amp;oldid=prev"/>
		<updated>2014-11-25T14:49:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;zh&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;←上一版本&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2014年11月25日 (二) 14:49的版本&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l142&quot; &gt;第142行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第142行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bit, name_ = requireany('&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;bit&lt;/del&gt;', '&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;bit32&lt;/del&gt;', 'bit.numberlua')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bit, name_ = requireany('&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;bit32&lt;/ins&gt;', '&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;bit&lt;/ins&gt;', 'bit.numberlua')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bxor = bit.bxor&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bxor = bit.bxor&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bnot = bit.bnot&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local bnot = bit.bnot&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>wiki:zh&gt;Liangent</name></author>
	</entry>
	<entry>
		<id>https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9942&amp;oldid=prev</id>
		<title>wiki:zh&gt;Liangent-bot：←建立内容为“--[[  LUA MODULE    digest.crc32 - CRC-32 checksum implemented entirely in Lua.  SYNOPSIS    local CRC = require 'digest.crc32lua'   print(CRC.crc32...”的新页面</title>
		<link rel="alternate" type="text/html" href="https://zh.enter-politics.com/index.php?title=%E6%A8%A1%E5%9D%97:Crc32lua&amp;diff=9942&amp;oldid=prev"/>
		<updated>2014-11-25T14:43:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=WP:AES&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:AES（页面不存在）&quot;&gt;←&lt;/a&gt;建立内容为“--[[  LUA MODULE    digest.crc32 - CRC-32 checksum implemented entirely in Lua.  SYNOPSIS    local CRC = require &amp;#039;digest.crc32lua&amp;#039;   print(CRC.crc32...”的新页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
LUA MODULE&lt;br /&gt;
&lt;br /&gt;
  digest.crc32 - CRC-32 checksum implemented entirely in Lua.&lt;br /&gt;
&lt;br /&gt;
SYNOPSIS&lt;br /&gt;
&lt;br /&gt;
  local CRC = require 'digest.crc32lua'&lt;br /&gt;
  print(CRC.crc32 'test') --&amp;gt; 0xD87F7E0C or -662733300&lt;br /&gt;
  &lt;br /&gt;
  assert(CRC.crc32('st', CRC.crc32('te')) == CRC.crc32 'test')&lt;br /&gt;
  &lt;br /&gt;
DESCRIPTION&lt;br /&gt;
&lt;br /&gt;
  This can be used to compute CRC-32 checksums on strings.&lt;br /&gt;
  This is similar to [1-2].&lt;br /&gt;
&lt;br /&gt;
API&lt;br /&gt;
&lt;br /&gt;
  Note: in the functions below, checksums are 32-bit integers stored in&lt;br /&gt;
  numbers.  The number format currently depends on the bit&lt;br /&gt;
  implementation--see DESIGN NOTES below.&lt;br /&gt;
&lt;br /&gt;
  CRC.crc32_byte(byte [, crc]) --&amp;gt; rcrc&lt;br /&gt;
  &lt;br /&gt;
    Returns CRC-32 checksum `rcrc` of byte `byte` (number 0..255) appended to&lt;br /&gt;
    a string with CRC-32 checksum `crc`.  `crc` defaults to 0 (empty string)&lt;br /&gt;
    if omitted.&lt;br /&gt;
&lt;br /&gt;
  CRC.crc32_string(s, crc) --&amp;gt; bcrc&lt;br /&gt;
&lt;br /&gt;
    Returns CRC-32 checksum `rcrc` of string `s` appended to&lt;br /&gt;
    a string with CRC-32 checksum `crc`.  `crc` defaults to 0 (empty string)&lt;br /&gt;
    if omitted.&lt;br /&gt;
  &lt;br /&gt;
  CRC.crc32(o, crc) --&amp;gt; bcrc&lt;br /&gt;
&lt;br /&gt;
    This invokes `crc32_byte` if `o` is a byte or `crc32_string` if `o`&lt;br /&gt;
    is a string.&lt;br /&gt;
  &lt;br /&gt;
  CRC.bit&lt;br /&gt;
&lt;br /&gt;
    This contains the underlying bit library used by the module.  It&lt;br /&gt;
    should be considered a read-only copy.&lt;br /&gt;
&lt;br /&gt;
DESIGN NOTES&lt;br /&gt;
&lt;br /&gt;
  Currently, this module exposes the underlying bit array implementation in CRC&lt;br /&gt;
  checksums returned.  In BitOp, bit arrays are 32-bit signed integer numbers&lt;br /&gt;
  (may be negative).  In Lua 5.2 'bit32' and 'bit.numberlua', bit arrays are&lt;br /&gt;
  32-bit unsigned integer numbers (non-negative).  This is subject to change&lt;br /&gt;
  in the future but is currently done due to (unconfirmed) performance&lt;br /&gt;
  implications.&lt;br /&gt;
  &lt;br /&gt;
  On platforms with 64-bit numbers, one way to normalize CRC&lt;br /&gt;
  checksums to be unsigned is to do `crcvalue % 2^32`,&lt;br /&gt;
  &lt;br /&gt;
  The name of this module is inspired by Perl `Digest::CRC*`.&lt;br /&gt;
&lt;br /&gt;
DEPENDENCIES&lt;br /&gt;
 &lt;br /&gt;
  Requires one of the following bit libraries:&lt;br /&gt;
&lt;br /&gt;
    BitOp &amp;quot;bit&amp;quot; -- bitop.luajit.org -- This is included in LuaJIT and also available&lt;br /&gt;
      for Lua 5.1/5.2.  This provides the fastest performance in LuaJIT.&lt;br /&gt;
    Lua 5.2 &amp;quot;bit32&amp;quot; -- www.lua.org/manual/5.2 -- This is provided in Lua 5.2&lt;br /&gt;
      and is preferred in 5.2 (unless &amp;quot;bit&amp;quot; also happens to be installed).&lt;br /&gt;
    &amp;quot;bit.numberlua&amp;quot; (&amp;gt;=000.003) -- https://github.com/davidm/lua-bit-numberlua&lt;br /&gt;
      This is slowest and used as a last resort.&lt;br /&gt;
      It is only a few times slower than &amp;quot;bit32&amp;quot; though.&lt;br /&gt;
&lt;br /&gt;
DOWNLOAD/INSTALLATION&lt;br /&gt;
&lt;br /&gt;
  If using LuaRocks:&lt;br /&gt;
    luarocks install lua-digest-crc32lua&lt;br /&gt;
&lt;br /&gt;
  Otherwise, download &amp;lt;https://github.com/davidm/lua-digest-crc32lua/zipball/master&amp;gt;.&lt;br /&gt;
  Alternately, if using git:&lt;br /&gt;
    git clone git://github.com/davidm/lua-digest-crc32lua.git&lt;br /&gt;
    cd lua-digest-crc32lua&lt;br /&gt;
  Optionally unpack:&lt;br /&gt;
    ./util.mk&lt;br /&gt;
  or unpack and install in LuaRocks:&lt;br /&gt;
    ./util.mk install &lt;br /&gt;
  &lt;br /&gt;
REFERENCES&lt;br /&gt;
&lt;br /&gt;
  [1] http://www.axlradius.com/freestuff/CRC32.java&lt;br /&gt;
  [2] http://www.gamedev.net/reference/articles/article1941.asp&lt;br /&gt;
  [3] http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/CRC32.html&lt;br /&gt;
  [4] http://www.dsource.org/projects/tango/docs/current/tango.io.digest.Crc32.html&lt;br /&gt;
  [5] http://pydoc.org/1.5.2/zlib.html#-crc32&lt;br /&gt;
  [6] http://www.python.org/doc/2.5.2/lib/module-binascii.html&lt;br /&gt;
 &lt;br /&gt;
LICENSE&lt;br /&gt;
&lt;br /&gt;
  (c) 2008-2011 David Manura.  Licensed under the same terms as Lua (MIT).&lt;br /&gt;
&lt;br /&gt;
  Permission is hereby granted, free of charge, to any person obtaining a copy&lt;br /&gt;
  of this software and associated documentation files (the &amp;quot;Software&amp;quot;), to deal&lt;br /&gt;
  in the Software without restriction, including without limitation the rights&lt;br /&gt;
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell&lt;br /&gt;
  copies of the Software, and to permit persons to whom the Software is&lt;br /&gt;
  furnished to do so, subject to the following conditions:&lt;br /&gt;
&lt;br /&gt;
  The above copyright notice and this permission notice shall be included in&lt;br /&gt;
  all copies or substantial portions of the Software.&lt;br /&gt;
&lt;br /&gt;
  THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR&lt;br /&gt;
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,&lt;br /&gt;
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE&lt;br /&gt;
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER&lt;br /&gt;
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,&lt;br /&gt;
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN&lt;br /&gt;
  THE SOFTWARE.&lt;br /&gt;
  (end license)&lt;br /&gt;
 &lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local M = {_TYPE='module', _NAME='digest.crc32', _VERSION='0.3.20111128'}&lt;br /&gt;
&lt;br /&gt;
local type = type&lt;br /&gt;
local require = require&lt;br /&gt;
local setmetatable = setmetatable&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
 Requires the first module listed that exists, else raises like `require`.&lt;br /&gt;
 If a non-string is encountered, it is returned.&lt;br /&gt;
 Second return value is module name loaded (or '').&lt;br /&gt;
 --]]&lt;br /&gt;
local function requireany(...)&lt;br /&gt;
  local errs = {}&lt;br /&gt;
  for _,name in ipairs{...} do&lt;br /&gt;
    if type(name) ~= 'string' then return name, '' end&lt;br /&gt;
    local ok, mod = pcall(require, name)&lt;br /&gt;
    if ok then return mod, name end&lt;br /&gt;
    errs[#errs+1] = mod&lt;br /&gt;
  end&lt;br /&gt;
  error(table.concat(errs, '\n'), 2)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local bit, name_ = requireany('bit', 'bit32', 'bit.numberlua')&lt;br /&gt;
local bxor = bit.bxor&lt;br /&gt;
local bnot = bit.bnot&lt;br /&gt;
local band = bit.band&lt;br /&gt;
local rshift = bit.rshift&lt;br /&gt;
&lt;br /&gt;
-- CRC-32-IEEE 802.3 (V.42)&lt;br /&gt;
local POLY = 0xEDB88320&lt;br /&gt;
&lt;br /&gt;
-- Memoize function pattern (like http://lua-users.org/wiki/FuncTables ).&lt;br /&gt;
local function memoize(f)&lt;br /&gt;
  local mt = {}&lt;br /&gt;
  local t = setmetatable({}, mt)&lt;br /&gt;
  function mt:__index(k)&lt;br /&gt;
    local v = f(k); t[k] = v&lt;br /&gt;
    return v&lt;br /&gt;
  end&lt;br /&gt;
  return t&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- CRC table.&lt;br /&gt;
local crc_table = memoize(function(i)&lt;br /&gt;
  local crc = i&lt;br /&gt;
  for _=1,8 do&lt;br /&gt;
    local b = band(crc, 1)&lt;br /&gt;
    crc = rshift(crc, 1)&lt;br /&gt;
    if b == 1 then crc = bxor(crc, POLY) end&lt;br /&gt;
  end&lt;br /&gt;
  return crc&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32_byte(byte, crc)&lt;br /&gt;
  crc = bnot(crc or 0)&lt;br /&gt;
  local v1 = rshift(crc, 8)&lt;br /&gt;
  local v2 = crc_table[bxor(crc % 256, byte)]&lt;br /&gt;
  return bnot(bxor(v1, v2))&lt;br /&gt;
end&lt;br /&gt;
local M_crc32_byte = M.crc32_byte&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32_string(s, crc)&lt;br /&gt;
  crc = crc or 0&lt;br /&gt;
  for i=1,#s do&lt;br /&gt;
    crc = M_crc32_byte(s:byte(i), crc)&lt;br /&gt;
  end&lt;br /&gt;
  return crc&lt;br /&gt;
end&lt;br /&gt;
local M_crc32_string = M.crc32_string&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function M.crc32(s, crc)&lt;br /&gt;
  if type(s) == 'string' then&lt;br /&gt;
    return M_crc32_string(s, crc)&lt;br /&gt;
  else&lt;br /&gt;
    return M_crc32_byte(s, crc)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
M.bit = bit  -- bit library used&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return M&lt;/div&gt;</summary>
		<author><name>wiki:zh&gt;Liangent-bot</name></author>
	</entry>
</feed>