Add support Roborock source

This commit is contained in:
Alexey Khit
2023-03-19 12:14:20 +03:00
parent 12a7b96289
commit e728643aad
14 changed files with 1257 additions and 30 deletions
+4 -4
View File
@@ -8,16 +8,16 @@ import (
"strings"
)
const digits = "0123456789abcdefghijklmnopqrstuvwxyz"
const maxSize = byte(len(digits))
const symbols = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"
func RandString(size byte) string {
// RandString base10 - numbers, base16 - hex, base36 - digits+letters, base64 - URL safe symbols
func RandString(size, base byte) string {
b := make([]byte, size)
if _, err := cryptorand.Read(b); err != nil {
panic(err)
}
for i := byte(0); i < size; i++ {
b[i] = digits[b[i]%maxSize]
b[i] = symbols[b[i]%base]
}
return string(b)
}