23 lines
356 B
Go
23 lines
356 B
Go
package operator
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
const sha256prefix = "sha256:"
|
|
|
|
func stringLikeSHA256Digest(some string) bool {
|
|
if strings.HasPrefix(some, sha256prefix) {
|
|
some = strings.TrimPrefix(some, sha256prefix)
|
|
}
|
|
_, err := hex.DecodeString(some)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if len(some) == 64 {
|
|
return true
|
|
}
|
|
return false
|
|
}
|