Source File
adler32.go
Belonging Package
hash/adler32
package adler32
import (
)
nmax = 5552
)
const Size = 4
func () hash.Hash32 {
:= new(digest)
.Reset()
return
}
func ( *digest) () int { return Size }
func ( *digest) () int { return 4 }
const (
magic = "adl\x01"
marshaledSize = len(magic) + 4
)
func ( *digest) () ([]byte, error) {
:= make([]byte, 0, marshaledSize)
= append(, magic...)
= appendUint32(, uint32(*))
return , nil
}
func ( *digest) ( []byte) error {
if len() < len(magic) || string([:len(magic)]) != magic {
return errors.New("hash/adler32: invalid hash state identifier")
}
if len() != marshaledSize {
return errors.New("hash/adler32: invalid hash state size")
}
* = digest(readUint32([len(magic):]))
return nil
}
func ( []byte, uint32) []byte {
:= [4]byte{
byte( >> 24),
byte( >> 16),
byte( >> 8),
byte(),
}
return append(, [:]...)
}
func ( []byte) uint32 {
_ = [3]
return uint32([3]) | uint32([2])<<8 | uint32([1])<<16 | uint32([0])<<24
}
func ( digest, []byte) digest {
, := uint32(&0xffff), uint32(>>16)
for len() > 0 {
var []byte
if len() > nmax {
, = [:nmax], [nmax:]
}
for len() >= 4 {
+= uint32([0])
+=
+= uint32([1])
+=
+= uint32([2])
+=
+= uint32([3])
+=
= [4:]
}
for , := range {
+= uint32()
+=
}
%= mod
%= mod
=
}
return digest(<<16 | )
}
func ( *digest) ( []byte) ( int, error) {
* = update(*, )
return len(), nil
}
func ( *digest) () uint32 { return uint32(*) }
func ( *digest) ( []byte) []byte {
:= uint32(*)
return append(, byte(>>24), byte(>>16), byte(>>8), byte())
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |