mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
20 lines
743 B
Go
20 lines
743 B
Go
package checksum
|
|
|
|
const (
|
|
// CharsetBase10 contains digits for base10 encoding.
|
|
CharsetBase10 = "0123456789"
|
|
// CharsetBase36 contains lowercase alphanumerics for base36.
|
|
CharsetBase36 = "abcdefghijklmnopqrstuvwxyz0123456789"
|
|
// CharsetBase62 contains mixed-case alphanumerics for base62.
|
|
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]
|
|
}
|