gmessages/libgm/crypto/generate.go

27 lines
390 B
Go
Raw Normal View History

2023-06-30 09:54:08 +00:00
package crypto
import (
"crypto/rand"
)
func GenerateKey(length int) ([]byte, error) {
key := make([]byte, length)
_, err := rand.Read(key)
if err != nil {
return nil, err
}
return key, nil
}
func GenerateKeys() ([]byte, []byte) {
key, err := GenerateKey(32)
if err != nil {
2023-06-30 11:48:50 +00:00
panic(err)
2023-06-30 09:54:08 +00:00
}
key2, err2 := GenerateKey(32)
if err2 != nil {
2023-06-30 11:48:50 +00:00
panic(err2)
2023-06-30 09:54:08 +00:00
}
return key, key2
2023-06-30 09:55:49 +00:00
}