refactor - pasdns can now look sane 3.0
This commit is contained in:
parent
57fbfbf059
commit
61f89c8067
7 changed files with 3 additions and 3 deletions
27
helper/stringfuckery.go
Normal file
27
helper/stringfuckery.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package helper
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
func Ender() string {
|
||||
return string(rune(0))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue