Files
ALPHA-TRAIN2/services/tiktak/server/auth/auth.go
T
bobiqq c231be0094
build-and-push / detect (push) Successful in 7s
build-and-push / build (${{ fromJSON(needs.detect.outputs.services) }}) (push) Failing after 3m33s
services
2026-08-26 11:04:23 +03:00

29 lines
396 B
Go

package auth
import (
"crypto/sha256"
"fmt"
)
var Salt = ""
func SetSalt(s string) {
Salt = s
}
func Validate(id string, hash string) bool {
return Generate(id) == hash
}
func Generate(id string) string {
return hashSha(Salt, id)
}
func hashSha(strings ...string) string {
h := sha256.New()
for _, s := range strings {
h.Write([]byte(s))
}
return fmt.Sprintf("%x", h.Sum(nil))
}