tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/lora/lorawan/bytes.go (about) 1 package lorawan 2 3 import "crypto/rand" 4 5 // reverseBytes reverses order of a given byte slice 6 func reverseBytes(s []byte) []byte { 7 result := make([]byte, len(s)) 8 for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { 9 result[i], result[j] = s[j], s[i] 10 } 11 return result 12 } 13 14 // GetRand16 returns 2 random bytes 15 func GetRand16() ([2]uint8, error) { 16 var randomBytes [2]byte 17 _, err := rand.Read(randomBytes[:]) 18 19 return randomBytes, err 20 }