Files
ag_tools/types/crc64.go
T

44 lines
685 B
Go

package types
import (
"fmt"
"archgrid.xyz/ag/toolsbox/hash/crc64"
)
type CRC64Algorithm string
const (
CRC64_ISO CRC64Algorithm = "iso"
CRC64_ECMA CRC64Algorithm = "ecma"
)
func (a *CRC64Algorithm) String() string {
return string(*a)
}
func (a *CRC64Algorithm) Set(s string) error {
switch s {
case "iso", "ecma":
*a = CRC64Algorithm(s)
return nil
default:
return fmt.Errorf("不支持的CRC64算法:%s", s)
}
}
func (a *CRC64Algorithm) Type() string {
return "CRC64Algorithm"
}
func (a CRC64Algorithm) IntoCRC64Mode() crc64.CRC64Mode {
switch a {
case CRC64_ISO:
return crc64.ISO
case CRC64_ECMA:
return crc64.ECMA
default:
return crc64.ISO
}
}