FIXED:
* Missed a Reset on the inetcksum.InetChecksumSimple.
This commit is contained in:
brent saner 2025-09-05 18:55:01 -04:00
parent 970acd0ee4
commit 965657d1b2
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 28 additions and 3 deletions

View File

@ -13,11 +13,17 @@ It provides [InetChecksum], which can be used as a:
* [io.Writer]
* [io.WriterTo]
and is concurrency-safe.
and allows one to retrieve the actual bytes that were checksummed.
It is also fully concurrency-safe.
There is also an [InetChecksumSimple] provided, which is more
tailored for performance/resource usage at the cost of concurrency
safety and data retention.
tailored for performance/resource usage at the cost of no concurrency
safety and no data retention, which can be used as a:
* [hash.Hash]
* [io.ByteWriter]
* [io.StringWriter]
* [io.Writer]
[RFC 1071]: https://datatracker.ietf.org/doc/html/rfc1071
[RFC 1141]: https://datatracker.ietf.org/doc/html/rfc1141

View File

@ -22,6 +22,15 @@ func (i *InetChecksumSimple) BlockSize() (blockSize int) {
return
}
// Reset resets the state of an InetChecksumSimple.
func (i *InetChecksumSimple) Reset() {
i.last = 0x00
i.sum = 0
i.last = 0x00
}
// Size returns how many bytes a checksum is. (It will always return 2.)
func (i *InetChecksumSimple) Size() (bufSize int) {
@ -151,3 +160,13 @@ func (i *InetChecksumSimple) WriteByte(c byte) (err error) {
return
}
// WriteString checksums a string. It conforms to [io.StringWriter].
func (i *InetChecksumSimple) WriteString(s string) (n int, err error) {
if n, err = i.Write([]byte(s)); err != nil {
return
}
return
}