func PackageMatchesAnyHash(loc PackageLocation, allowed []Hash) (bool, error) {
	var v1Hash, zipHash Hash
	for _, want := range allowed {
		switch want.Scheme() {
		case HashScheme1:
			if v1Hash == NilHash {
				got, err := PackageHashV1(loc)
				if err != nil {
					return false, err
				}
				v1Hash = got
			}
			if v1Hash == want {
				return true, nil
			}
		case HashSchemeZip:
			archiveLoc, ok := loc.(PackageLocalArchive)
			if !ok {
				continue
			}
			if zipHash == NilHash {
				got, err := PackageHashLegacyZipSHA(archiveLoc)
				if err != nil {
					return false, err
				}
				zipHash = got
			}
			if zipHash == want {
				return true, nil
			}
		default:
			continue
		}
	}
	return false, nil
}
PackageMatchesAnyHash returns true if the package at the given location
matches at least one of the given hashes, or false otherwise.

If it cannot read from the given location, PackageMatchesAnyHash returns an
error. Unlike the singular PackageMatchesHash, PackageMatchesAnyHash
considers unsupported hash formats as successfully non-matching, rather
than returning an error.

PackageMatchesAnyHash can be used only with the two local package location
types PackageLocalDir and PackageLocalArchive, because it needs to access the
contents of the indicated package in order to compute the hash. If given
a non-local location this function will always return an error.
package getproviders
import (
	"crypto/sha256"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strings"
	"golang.org/x/mod/sumdb/dirhash"
)
type Hash string
const NilHash = Hash("")
func ParseHash(s string) (Hash, error) {
	colon := strings.Index(s, ":")
	if colon < 1 {  
		return NilHash, fmt.Errorf("hash string must start with a scheme keyword followed by a colon")
	}
	return Hash(s), nil
}
func MustParseHash(s string) Hash {
	hash, err := ParseHash(s)
	if err != nil {
		panic(err.Error())
	}
	return hash
}
func (h Hash) Scheme() HashScheme {
	colon := strings.Index(string(h), ":")
	if colon < 0 {
		panic(fmt.Sprintf("invalid hash string %q", h))
	}
	return HashScheme(h[:colon+1])
}
func (h Hash) HasScheme(want HashScheme) bool {
	return h.Scheme() == want
}
func (h Hash) Value() string {
	colon := strings.Index(string(h), ":")
	if colon < 0 {
		panic(fmt.Sprintf("invalid hash string %q", h))
	}
	return string(h[colon+1:])
}
func (h Hash) String() string {
	return string(h)
}
func (h Hash) GoString() string {
	if h == NilHash {
		return "getproviders.NilHash"
	}
	switch scheme := h.Scheme(); scheme {
	case HashScheme1:
		return fmt.Sprintf("getproviders.HashScheme1.New(%q)", h.Value())
	case HashSchemeZip:
		return fmt.Sprintf("getproviders.HashSchemeZip.New(%q)", h.Value())
	default:
		return fmt.Sprintf("getproviders.HashScheme(%q).New(%q)", scheme, h.Value())
	}
}
type HashScheme string
const (
	HashScheme1 HashScheme = HashScheme("h1:")
	HashSchemeZip HashScheme = HashScheme("zh:")
)
func (hs HashScheme) New(value string) Hash {
	return Hash(string(hs) + value)
}
func PackageHash(loc PackageLocation) (Hash, error) {
	return PackageHashV1(loc)
}
func PackageMatchesHash(loc PackageLocation, want Hash) (bool, error) {
	switch want.Scheme() {
	case HashScheme1:
		got, err := PackageHashV1(loc)
		if err != nil {
			return false, err
		}
		return got == want, nil
	case HashSchemeZip:
		archiveLoc, ok := loc.(PackageLocalArchive)
		if !ok {
			return false, fmt.Errorf(`ziphash scheme ("zh:" prefix) is not supported for unpacked provider packages`)
		}
		got, err := PackageHashLegacyZipSHA(archiveLoc)
		if err != nil {
			return false, err
		}
		return got == want, nil
	default:
		return false, fmt.Errorf("unsupported hash format (this may require a newer version of Terraform)")
	}
}