func (a Algorithm) FromReader(rd io.Reader) (Digest, error) {
	digester := a.New()
	if _, err := io.Copy(digester.Hash(), rd); err != nil {
		return "", err
	}
	return digester.Digest(), nil
}
FromReader returns the digest of the reader using the algorithm.
package digest
import (
	"crypto"
	"fmt"
	"hash"
	"io"
)
type Algorithm string
const (
	SHA256 Algorithm = "sha256"  
	SHA384 Algorithm = "sha384"  
	SHA512 Algorithm = "sha512"  
	Canonical = SHA256
)
var (
	algorithms = map[Algorithm]crypto.Hash{
		SHA256: crypto.SHA256,
		SHA384: crypto.SHA384,
		SHA512: crypto.SHA512,
	}
)
func (a Algorithm) Available() bool {
	h, ok := algorithms[a]
	if !ok {
		return false
	}
	return h.Available()
}
func (a Algorithm) String() string {
	return string(a)
}
func (a Algorithm) Size() int {
	h, ok := algorithms[a]
	if !ok {
		return 0
	}
	return h.Size()
}
func (a *Algorithm) Set(value string) error {
	if value == "" {
		*a = Canonical
	} else {
		*a = Algorithm(value)
	}
	return nil
}
func (a Algorithm) New() Digester {
	return &digester{
		alg:  a,
		hash: a.Hash(),
	}
}
func (a Algorithm) Hash() hash.Hash {
	if !a.Available() {
		panic(fmt.Sprintf("%v not available (make sure it is imported)", a))
	}
	return algorithms[a].New()
}