github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/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 }