You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
452 B
Go

package check
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io/ioutil"
)
func PrintSha256(path string) string {
strContent := readFileToStr(path)
sum := sha256.Sum256([]byte(strContent))
//fmt.Printf("sha256: %x\n", sum)
return hex.EncodeToString(sum[:])
}
func readFileToStr(path string) string {
content, err := ioutil.ReadFile(path)
if err != nil {
fmt.Println("read file failed, err:", err)
return ""
}
return string(content)
}