photoprism/pkg/checksum/charset.go
Michael Mayer 01da5bdec7 CRC32: Move checksum generation to a dedicated package
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-20 14:56:07 +01:00

17 lines
531 B
Go

package checksum
const (
CharsetBase36 = "abcdefghijklmnopqrstuvwxyz0123456789"
CharsetBase62 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)
// Char returns a simple checksum byte based on Crc32 and the 62 characters specified in CharsetBase62.
func Char(data []byte) byte {
return CharsetBase62[Crc32(data)%62]
}
// Base36 returns a simple checksum byte based on Crc32 and the 36 lower-case characters specified in CharsetBase36.
func Base36(data []byte) byte {
return CharsetBase36[Crc32(data)%36]
}