github.com/moontrade/nogc@v0.1.7/hash/adler32.go (about)

     1  package hash
     2  
     3  func Adler32(v uint32) uint32 {
     4  	const mod = 65521
     5  	var d uint32 = 1
     6  	s1, s2 := d&0xffff, d>>16
     7  
     8  	s1 += uint32(byte(v))
     9  	s2 += s1
    10  	s1 += uint32(byte(v >> 8))
    11  	s2 += s1
    12  	s1 += uint32(byte(v >> 16))
    13  	s2 += s1
    14  	s1 += uint32(byte(v >> 24))
    15  	s2 += s1
    16  	s1 %= mod
    17  	s2 %= mod
    18  	return s2<<16 | s1
    19  }