dsfx/shared/dcrypto/rand.go

13 lines
262 B
Go
Raw Normal View History

2025-03-07 21:05:37 -05:00
package dcrypto
import "crypto/rand"
// Challenge generates a random challenge of n bytes.
func Challenge(n int) []byte {
challenge := make([]byte, n)
if _, err := rand.Read(challenge); err != nil || len(challenge) != n {
return nil
}
return challenge
}