Adler32 structv0.1.0
pub struct Adler32 {
// private fields
}
Copy, holding only the two sums, so passing one by value takes a snapshot of the checksum so far.
Constructors
Adler32
pub func Adler32() -> Adler32
Constructs a checksum with nothing written into it yet.
Returns: a hasher with nothing written to it yet
Methods
Reset
pub func Reset(self: &var Adler32)
Puts the checksum back to where Adler32() leaves one. Everything written so far is forgotten.
Value
pub func Value(self: &Adler32) -> uint32
The checksum of everything written so far: the second sum in the high half and the first in the low half. Writing more continues from here rather than starting over.
Returns: the checksum
Implements Hasher
Adler32 conforms to Hasher.
Write
pub func Write(
self: &var Adler32,
bytes: *byte,
length: uint
)
Adds length bytes at bytes to the checksum. A zero length changes nothing and is the one case in which
bytes may be null. Splitting a message across several writes gives the same answer as one write.
Runs in time proportional to length and allocates nothing.
| Name | Type | Description |
|---|---|---|
bytes | *byte | the bytes to absorb |
length | uint | how many bytes; zero absorbs nothing |
Finish
pub func Finish(self: &var Adler32) -> uint64
The checksum of everything written so far, widened to 64 bits; the upper half is always zero.
Returns: the checksum