2024-06-08 20:28:43 +02:00
|
|
|
package helper
|
|
|
|
|
2024-07-15 20:24:27 +02:00
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
"math/big"
|
|
|
|
)
|
|
|
|
|
2024-06-08 20:28:43 +02:00
|
|
|
func Ender() string {
|
|
|
|
return string(rune(0))
|
|
|
|
}
|
|
|
|
|
2024-07-14 04:49:21 +02:00
|
|
|
func StringToByteWithEnd(str string) []byte {
|
2024-06-08 20:28:43 +02:00
|
|
|
return append([]byte(str), byte(0))
|
|
|
|
}
|
2024-07-15 20:24:27 +02:00
|
|
|
|
|
|
|
func GetRandString(length int) string {
|
|
|
|
const charset = "qwertyuiopasdfghjklzxcvbnm"
|
|
|
|
result := make([]byte, length)
|
|
|
|
for i := range result {
|
|
|
|
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(charset))))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
result[i] = charset[num.Int64()]
|
|
|
|
}
|
|
|
|
return string(result)
|
|
|
|
}
|