Pure Ruby implementation of CRC32?

Anyone seen it?

I need to whip up some sfv files on windows…

Thanks,

Robert

Hi,

“Robert Feldt” feldt@ce.chalmers.se wrote in message
news:Pine.GSO.4.44.0208301404310.28565-100000@duquesne.ce.chalmers.se

Anyone seen it?

I need to whip up some sfv files on windows…

Thanks,

Robert

Try this

def crc32©
n = c.length
r = 0xFFFFFFFF
n.times do |i|
r ^= c[i]
8.times do
if (r & 1)!=0
r = (r>>1) ^ 0xEDB88320
else
r >>= 1
end
end
end
r ^ 0xFFFFFFFF
end

str = "test string"
crc = crc32(str)

Park Heesob

Or (more rubyish)

def crc32©
r = 0xFFFFFFFF
c.each_byte do |b|
r ^= b
8.times do
r = (r>>1) ^ (0xEDB88320 * (r & 1))
end
end
r ^ 0xFFFFFFFF
end

-billy.

···

On Fri, Aug 30, 2002 at 09:54:54PM +0900, Park Heesob wrote:

“Robert Feldt” feldt@ce.chalmers.se wrote in message
news:Pine.GSO.4.44.0208301404310.28565-100000@duquesne.ce.chalmers.se

Try this

def crc32©
n = c.length
r = 0xFFFFFFFF
n.times do |i|
r ^= c[i]
8.times do
if (r & 1)!=0
r = (r>>1) ^ 0xEDB88320
else
r >>= 1
end
end
end
r ^ 0xFFFFFFFF
end


Meisterbohne Söflinger Straße 100 Tel: +49-731-399 499-0
eLösungen 89077 Ulm Fax: +49-731-399 499-9