Hasher returns a hasher corresponding to the checksum type. Returns nil if no checksum.
()
| 239 | // Hasher returns a hasher corresponding to the checksum type. |
| 240 | // Returns nil if no checksum. |
| 241 | func (c ChecksumType) Hasher() hash.Hash { |
| 242 | switch c & checksumMask { |
| 243 | case ChecksumCRC32: |
| 244 | return crc32.NewIEEE() |
| 245 | case ChecksumCRC32C: |
| 246 | return crc32.New(crc32.MakeTable(crc32.Castagnoli)) |
| 247 | case ChecksumSHA1: |
| 248 | return sha1.New() |
| 249 | case ChecksumSHA256: |
| 250 | return sha256.New() |
| 251 | case ChecksumCRC64NVME: |
| 252 | return crc64nvme.New() |
| 253 | case ChecksumMD5: |
| 254 | return md5.New() |
| 255 | case ChecksumSHA512: |
| 256 | return sha512.New() |
| 257 | case ChecksumXXHash64: |
| 258 | return xxhash.New() |
| 259 | case ChecksumXXHash3: |
| 260 | return xxh3.New() |
| 261 | case ChecksumXXHash128: |
| 262 | return xxh3.New128() |
| 263 | } |
| 264 | return nil |
| 265 | } |
| 266 | |
| 267 | // IsSet returns whether the type is valid and known. |
| 268 | func (c ChecksumType) IsSet() bool { |
no outgoing calls
no test coverage detected