github.com/docker/engine@v22.0.0-20211208180946-d456264580cf+incompatible/libnetwork/resolvconf/utils.go (about)

     1  package resolvconf
     2  
     3  import (
     4  	"crypto/sha256"
     5  	"encoding/hex"
     6  	"io"
     7  )
     8  
     9  // hashData returns the sha256 sum of src.
    10  func hashData(src io.Reader) (string, error) {
    11  	h := sha256.New()
    12  	if _, err := io.Copy(h, src); err != nil {
    13  		return "", err
    14  	}
    15  	return "sha256:" + hex.EncodeToString(h.Sum(nil)), nil
    16  }