Sha256: f8c12d2291cd72c2f1e066d475121010e05f7fe476de85d1ed58f9508cae0ed7
Contents?: true
Size: 464 Bytes
Versions: 3
Compression:
Stored size: 464 Bytes
Contents
class FastCache::CRC32 def initialize(string = nil) @crc = 0xFFFFFFFF self << string if string end def <<(string) string.size.times do |i| @crc ^= string[i] 8.times do if (@crc & 1).zero? @crc >>= 1 else @crc = (@crc >> 1) ^ 0xEDB88320 end end end self end def digest [@crc ^ 0xFFFFFFFF].pack('N') end def hexdigest (@crc ^ 0xFFFFFFFF).to_s(16) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
binary42-fastcache-0.1 | lib/fastcache/hash/crc32.rb |
binary42-fastcache-0.2 | lib/fastcache/hash/crc32.rb |
binary42-fastcache-0.3 | lib/fastcache/hash/crc32.rb |