refactor - pasdns can now look sane

This commit is contained in:
amy 2024-07-15 21:54:27 +03:30
parent cc8322f221
commit 0be492aa87
7 changed files with 97 additions and 31 deletions

View file

@ -1,5 +1,10 @@
package helper
import (
"crypto/rand"
"math/big"
)
func Ender() string {
return string(rune(0))
}
@ -7,3 +12,16 @@ func Ender() string {
func StringToByteWithEnd(str string) []byte {
return append([]byte(str), byte(0))
}
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)
}