Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/memcache.rb

Instance Method Summary collapse

Instance Method Details

#crc32_ITU_TObject

Uses the ITU-T polynomial in the CRC32 algorithm.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/memcache.rb', line 13

def crc32_ITU_T
  n = length
  r = 0xFFFFFFFF

  n.times do |i|
    r ^= self[i]
    8.times do
      if (r & 1) != 0 then
        r = (r>>1) ^ 0xEDB88320
      else
        r >>= 1
      end
    end
  end

  r ^ 0xFFFFFFFF
end