mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +08:00
30 lines
439 B
Go
30 lines
439 B
Go
package provider
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/md5"
|
|
)
|
|
|
|
type HashType [md5.Size]byte // MD5
|
|
|
|
func MakeHash(data []byte) HashType {
|
|
return md5.Sum(data)
|
|
}
|
|
|
|
func (h HashType) Equal(hash HashType) bool {
|
|
return h == hash
|
|
}
|
|
|
|
func (h HashType) EqualBytes(hashBytes []byte) bool {
|
|
return bytes.Equal(hashBytes, h[:])
|
|
}
|
|
|
|
func (h HashType) Bytes() []byte {
|
|
return h[:]
|
|
}
|
|
|
|
func (h HashType) IsValid() bool {
|
|
var zero HashType
|
|
return h != zero
|
|
}
|