Encode idents to hex instead of base64

base64 strings may contain characters rejected by ident clients such
as "+". Use hex encoding and shorten the string a little.
This commit is contained in:
Simon Ser 2020-08-19 11:24:25 +02:00
parent ca40e79855
commit 78361f0b1e
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -2,8 +2,8 @@ package soju
import ( import (
"crypto/sha256" "crypto/sha256"
"encoding/base64"
"encoding/binary" "encoding/binary"
"encoding/hex"
"fmt" "fmt"
"time" "time"
@ -110,7 +110,7 @@ func userIdent(u *User) string {
var b [64]byte var b [64]byte
binary.LittleEndian.PutUint64(b[:], uint64(u.ID)) binary.LittleEndian.PutUint64(b[:], uint64(u.ID))
h := sha256.Sum256(b[:]) h := sha256.Sum256(b[:])
return base64.RawStdEncoding.EncodeToString(h[:]) return hex.EncodeToString(h[:16])
} }
func (net *network) run() { func (net *network) run() {