ag_tools/types/crc64.go

44 lines
685 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}
}