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