2022-01-14 21:36:49 +00:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"encoding/hex"
|
|
|
|
)
|
|
|
|
|
2023-06-21 10:31:33 +00:00
|
|
|
func hash(data []byte) []byte {
|
2022-01-14 21:36:49 +00:00
|
|
|
if len(data) == 0 {
|
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
b := sha256.Sum256(data)
|
|
|
|
return b[:]
|
|
|
|
}
|
|
|
|
|
|
|
|
func HashString(data string) string {
|
2023-06-21 10:31:33 +00:00
|
|
|
return hex.EncodeToString(hash([]byte(data)))
|
2022-01-14 21:36:49 +00:00
|
|
|
}
|