class ConvertMacToint
def initialize
end
def crc32(c)
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
puts r ^ 0xFFFFFFFF
end
end
mac = ConvertMacToint.new
mac.crc32("aa::bb::cc::dd::ee::ff")
用了下这样的方法,不知道对不