20 lines
378 B
Go
20 lines
378 B
Go
|
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]
|
||
|
}
|