github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/utils/hash.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package utils 5 6 import ( 7 "crypto/sha256" 8 "fmt" 9 ) 10 11 func HashSha256(text string) string { 12 hash := sha256.New() 13 hash.Write([]byte(text)) 14 15 return fmt.Sprintf("%x", hash.Sum(nil)) 16 }