Commit 4b701a45 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

zguid

parent 3ed158cc
......@@ -7,6 +7,7 @@ import (
_ "git.barsukov.pro/barsukov/zgo/zdb"
_ "git.barsukov.pro/barsukov/zgo/zdebug"
_ "git.barsukov.pro/barsukov/zgo/zgin"
_ "git.barsukov.pro/barsukov/zgo/zguid"
_ "git.barsukov.pro/barsukov/zgo/zjson"
_ "git.barsukov.pro/barsukov/zgo/zq"
_ "git.barsukov.pro/barsukov/zgo/zquit"
......
package zguid
import (
"crypto/md5"
"fmt"
"github.com/google/uuid"
)
func New() string {
return uuid.NewString()
}
func Hash(a any) string {
b := md5.Sum([]byte(fmt.Sprintf("%v", a)))
return fmt.Sprintf("%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13], b[14], b[15])
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment