summaryrefslogblamecommitdiff
path: root/pkg/model/uid.go
blob: 85fda18beae6fdc97e2321240ac8a0be7b5e0611 (plain) (tree)


















                                                                                    
package model

import (
	"crypto/sha256"
	"encoding/base64"
	"strings"
)

func UIDFromMessage(msg *Message) string {
	return UIDFromText(msg.PointMessage())
}

func UIDFromText(text string) string {
	h := sha256.Sum256([]byte(text))
	id := base64.StdEncoding.EncodeToString(h[:])
	id = strings.NewReplacer("+", "A", "/", "Z", "-", "A", "_", "Z").Replace(id)

	return id[0:20]
}