gmessages/libgm/crypto/generate.go
2023-07-16 14:36:13 +03:00

15 lines
237 B
Go

package crypto
import (
"crypto/rand"
"fmt"
)
func GenerateKey(length int) []byte {
key := make([]byte, length)
_, err := rand.Read(key)
if err != nil {
panic(fmt.Errorf("failed to read random bytes: %w", err))
}
return key
}