Rewrite HomeKit client

This commit is contained in:
Alexey Khit
2023-08-30 21:52:06 +03:00
parent 7d65c60711
commit 22787b979d
30 changed files with 1094 additions and 916 deletions
+6 -7
View File
@@ -22,12 +22,16 @@ func Now90000() uint32 {
const symbols = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"
// RandString base10 - numbers, base16 - hex, base36 - digits+letters, base64 - URL safe symbols
// RandString base10 - numbers, base16 - hex, base36 - digits+letters
// base64 - URL safe symbols, base0 - crypto random
func RandString(size, base byte) string {
b := make([]byte, size)
if _, err := rand.Read(b); err != nil {
panic(err)
}
if base == 0 {
return string(b)
}
for i := byte(0); i < size; i++ {
b[i] = symbols[b[i]%base]
}
@@ -50,12 +54,7 @@ func Between(s, sub1, sub2 string) string {
}
s = s[i+len(sub1):]
if len(sub2) == 1 {
i = strings.IndexByte(s, sub2[0])
} else {
i = strings.Index(s, sub2)
}
if i >= 0 {
if i = strings.Index(s, sub2); i >= 0 {
return s[:i]
}