use hostname instead of MAC address to work with docker environments

This commit is contained in:
David Zhao
2021-02-17 17:51:54 -08:00
parent 0eb9734111
commit b52354623c
2 changed files with 18 additions and 1 deletions
+12
View File
@@ -1,7 +1,10 @@
package utils
import (
"crypto/sha1"
"github.com/lithammer/shortuuid/v3"
"github.com/lytics/base62"
)
const (
@@ -15,3 +18,12 @@ const (
func NewGuid(prefix string) string {
return prefix + shortuuid.New()[:12]
}
// Creates a hashed ID from a unique string
func HashedID(str string) string {
h := sha1.New()
h.Write([]byte(str))
val := h.Sum(nil)
return base62.StdEncoding.EncodeToString(val)
}