Files
llgo/_demo/go/randcrypt/rand.go

19 lines
270 B
Go
Raw Normal View History

2024-07-31 01:27:08 +08:00
package main
import (
"crypto/rand"
"fmt"
)
func main() {
c := 10
b := make([]byte, c)
_, err := rand.Read(b)
if err != nil {
fmt.Println("error:", err)
return
}
// The slice should now contain random bytes instead of only zeroes.
fmt.Printf("%x\n", b)
}