Files
mautrix-telegram/pkg/gotd/session/tdesktop/md5.go
T
2025-06-27 20:03:37 -07:00

21 lines
361 B
Go

package tdesktop
import (
"crypto/md5" // #nosec G501
"encoding/hex"
"strings"
)
func tdesktopMD5(s string) string {
hash := md5.Sum([]byte(s)) // #nosec G401
for i := range hash {
hash[i] = hash[i]<<4 | hash[i]>>4
}
hexed := hex.EncodeToString(hash[:])
return strings.ToUpper(hexed)
}
func fileKey(s string) string {
return tdesktopMD5(s)[:16]
}