Files
mautrix-telegram/pkg/gotd/crypto/session_id.go
T
2025-06-27 20:03:37 -07:00

18 lines
395 B
Go

package crypto
import (
"encoding/binary"
"io"
)
// NewSessionID generates new random int64 from reader.
//
// Use crypto/rand.Reader if session id should be cryptographically safe.
func NewSessionID(reader io.Reader) (int64, error) {
bytes := make([]byte, 8)
if _, err := io.ReadFull(reader, bytes); err != nil {
return 0, err
}
return int64(binary.LittleEndian.Uint64(bytes)), nil
}