blob: 85fda18beae6fdc97e2321240ac8a0be7b5e0611 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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]
}
|