v1.10.1
FIXED: * Missed a Reset on the inetcksum.InetChecksumSimple.
This commit is contained in:
parent
970acd0ee4
commit
965657d1b2
@ -13,11 +13,17 @@ It provides [InetChecksum], which can be used as a:
|
|||||||
* [io.Writer]
|
* [io.Writer]
|
||||||
* [io.WriterTo]
|
* [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
|
There is also an [InetChecksumSimple] provided, which is more
|
||||||
tailored for performance/resource usage at the cost of concurrency
|
tailored for performance/resource usage at the cost of no concurrency
|
||||||
safety and data retention.
|
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 1071]: https://datatracker.ietf.org/doc/html/rfc1071
|
||||||
[RFC 1141]: https://datatracker.ietf.org/doc/html/rfc1141
|
[RFC 1141]: https://datatracker.ietf.org/doc/html/rfc1141
|
||||||
|
@ -22,6 +22,15 @@ func (i *InetChecksumSimple) BlockSize() (blockSize int) {
|
|||||||
return
|
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.)
|
// Size returns how many bytes a checksum is. (It will always return 2.)
|
||||||
func (i *InetChecksumSimple) Size() (bufSize int) {
|
func (i *InetChecksumSimple) Size() (bufSize int) {
|
||||||
|
|
||||||
@ -151,3 +160,13 @@ func (i *InetChecksumSimple) WriteByte(c byte) (err error) {
|
|||||||
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user