|
|
@@ -34,15 +34,15 @@ var PrimeSet = [256]uint32{ |
|
|
|
2625015193, 2795623993, 3911522341, 3507684083, 3553065317, 3987511039, 2786582429, 2534596151, |
|
|
|
} |
|
|
|
|
|
|
|
func slct(n uint64) uint32 { |
|
|
|
return PrimeSet[n&0xff] |
|
|
|
func selectPrime(n uint64) uint64 { |
|
|
|
return uint64(PrimeSet[n&0xff]) |
|
|
|
} |
|
|
|
|
|
|
|
func Engine(buffer string, length int, accumulator uint64) uint64 { |
|
|
|
for i := 0; i < length; i++ { |
|
|
|
b := buffer[i] |
|
|
|
var accumulator1 uint64 = uint64(slct(accumulator) + uint32(b)) |
|
|
|
var accumulator2 uint64 = ^accumulator * uint64(slct(uint64(b))) |
|
|
|
b := uint64(buffer[i]) |
|
|
|
var accumulator1 uint64 = selectPrime(accumulator) + b |
|
|
|
var accumulator2 uint64 = ^accumulator * selectPrime(b) |
|
|
|
var accumulator3 = accumulator >> (32 + ((b & 0x1F) ^ (b >> 5))) |
|
|
|
accumulator = accumulator1 + accumulator2 + accumulator3 |
|
|
|
} |