github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/integration/helpers/sha.go (about)

     1  package helpers
     2  
     3  import (
     4  	"crypto/sha1"
     5  	"fmt"
     6  	"io"
     7  	"os"
     8  
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  // Sha1Sum calculates the SHA1 sum of a file.
    13  func Sha1Sum(path string) string {
    14  	f, err := os.Open(path)
    15  	Expect(err).ToNot(HaveOccurred())
    16  	defer f.Close()
    17  
    18  	hash := sha1.New()
    19  	_, err = io.Copy(hash, f)
    20  	Expect(err).ToNot(HaveOccurred())
    21  
    22  	return fmt.Sprintf("%x", hash.Sum(nil))
    23  }