You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-sendxmpp/helpers.go

35 lines
687 B
Go

// Copyright 2022 Martin Dosch.
// Use of this source code is governed by the BSD-2-clause
// license that can be found in the LICENSE file.
package main
import (
"crypto/rand"
"fmt"
"log"
mrand "math/rand"
"time"
)
func getRpad() string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;?!+-_§$%&/()=")
mrand.Seed(time.Now().UnixNano())
s := make([]rune, mrand.Intn(30)+20)
for i := range s {
s[i] = letters[mrand.Intn(len(letters))]
}
return string(s)
}
func getID() string {
b := make([]byte, 12)
_, err := rand.Read(b)
if err != nil {
log.Fatal(err)
}
id := fmt.Sprintf("%x-%x-%x", b[0:4], b[4:8], b[8:])
return id
}